Exemplo n.º 1
0
 public HttpErrorFlyout(int errorCode, string errorMessage = null)
 {
     Content = new HttpErrorPage(errorCode, errorMessage)
     {
         Background = new Microsoft.UI.Xaml.Media.SolidColorBrush(Microsoft.UI.Colors.Transparent)
     };
 }
Exemplo n.º 2
0
        /// <summary>
        /// Renders the view.
        /// </summary>
        /// <param name="StatusCode">The status code.</param>
        /// <returns></returns>
        private string RenderView(int StatusCode)
        {
            var technicalContactEmail = System.Configuration.ConfigurationManager.AppSettings["TechnicalContactEmail"];

            var ErrorList = new List <HttpErrorPage>();

            ErrorList.Add(new HttpErrorPage()
            {
                ErrorCode = 400, ErrorTitle = "Bad Request ", ErrorDescription = "The server cannot process the request due to something that is perceived to be a client error.", TechnicalContact = technicalContactEmail
            });
            ErrorList.Add(new HttpErrorPage()
            {
                ErrorCode = 401, ErrorTitle = "Unauthorized", ErrorDescription = "The requested resource requires authentication.", TechnicalContact = technicalContactEmail
            });
            ErrorList.Add(new HttpErrorPage()
            {
                ErrorCode = 500, ErrorTitle = "Webservice currently unavailable ", ErrorDescription = "An unexpected condition was encountered.Our service team has been dispatched to bring it back online.", TechnicalContact = technicalContactEmail
            });

            var response = HttpContext.Current.Response;

            var z = ErrorList.Where(x => x.ErrorCode == StatusCode).FirstOrDefault();

            if (z == null)
            {
                z = new HttpErrorPage()
                {
                    ErrorCode        = StatusCode,
                    ErrorTitle       = "Unknown Error",
                    ErrorDescription = "An unknown error has occured.",
                    TechnicalContact = technicalContactEmail
                };
            }


            // Create an arbitrary controller instance
            var controller = ViewRenderer.CreateController <FakeController>();

            string html = ViewRenderer.RenderView(
                string.Format("~/views/shared/HttpErrorPages/Error.cshtml", StatusCode.ToString()),
                z,
                controller.ControllerContext);

            return(html);
        }