예제 #1
0
        /// <summary>
        /// Renders the error response.
        /// </summary>
        public static Task RenderErrorResponse(IOwinContext context, Exception error)
        {
            context.Response.ContentType = "text/html";

            var template = new ErrorPageTemplate()
            {
                Exception        = error,
                ErrorCode        = context.Response.StatusCode,
                ErrorDescription = ((HttpStatusCode)context.Response.StatusCode).ToString(),
                IpAddress        = context.Request.RemoteIpAddress,
                CurrentUserName  = context.Request.User != null ? context.Request.User.Identity.Name : "",
                Url  = context.Request.Uri.ToString(),
                Verb = context.Request.Method
            };

            if (error is ParserException)
            {
                template.FileName       = ((ParserException)error).FileName;
                template.LineNumber     = ((ParserException)error).LineNumber;
                template.PositionOnLine = ((ParserException)error).PositionOnLine;
            }

            var text = template.TransformText();

            return(context.Response.WriteAsync(text));
        }
예제 #2
0
        /// <summary>
        /// Renders the error response.
        /// </summary>
        public static Task RenderErrorResponse(IOwinContext context, Exception error)
        {
            context.Response.ContentType = "text/html";

            var template = new ErrorPageTemplate()
            {
                Exception = error,
                ErrorCode = context.Response.StatusCode,
                ErrorDescription = ((HttpStatusCode)context.Response.StatusCode).ToString(),
                IpAddress = context.Request.RemoteIpAddress,
                CurrentUserName = context.Request.User != null ? context.Request.User.Identity.Name : "",
                Url = context.Request.Uri.ToString(),
                Verb = context.Request.Method
            };
            if (error is ParserException)
            {
                template.FileName = ((ParserException)error).FileName;
                template.LineNumber = ((ParserException)error).LineNumber;
                template.PositionOnLine = ((ParserException)error).PositionOnLine;
            }

            var text = template.TransformText();
            return context.Response.WriteAsync(text);
        }