Skip to content

Commit f237e68

Browse files
committed
[fix] web context is not available on WriteErrorResponseAsync
1 parent 66d5e32 commit f237e68

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Simplify.Web/Middleware/SimplifyWebRequestMiddleware.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Simplify.Web.Diagnostics.Measurements;
88
using Simplify.Web.Diagnostics.Trace;
99
using Simplify.Web.Modules;
10-
using Simplify.Web.Modules.Context;
1110
using Simplify.Web.RequestHandling;
1211
using Simplify.Web.Settings;
1312

@@ -86,12 +85,12 @@ internal static bool ProcessOnException(Exception e)
8685

8786
private static async Task WriteErrorResponseAsync(this HttpContext context, ILifetimeScope scope, Exception e)
8887
{
89-
var webContext = scope.Resolver.Resolve<IWebContextProvider>().Get();
88+
var isAjax = context.Request.Headers.ContainsKey("X-Requested-With");
9089

91-
if (webContext.IsAjax)
90+
if (isAjax)
9291
context.Response.ContentType = "text/plain";
9392

94-
await context.Response.WriteAsync(scope.GenerateErrorResponse(e, webContext.IsAjax));
93+
await context.Response.WriteAsync(scope.GenerateErrorResponse(e, isAjax));
9594
}
9695

9796
private static string GenerateErrorResponse(this ILifetimeScope scope, Exception e, bool minimalStyle)

0 commit comments

Comments
 (0)