StackExchange.Exceptional icon indicating copy to clipboard operation
StackExchange.Exceptional copied to clipboard

error route handler not rendering ui properly with asp.net core 3.x razor pages

Open fingers10 opened this issue 4 years ago • 4 comments

I came across this awesome nuget package to handle and log exceptions in asp.net core. I tried this in my razor pages application and things worked fine. However when I try to use error routes to see the errors, the page is not getting displayed properly.

My Error Page:

public class ErrorModel : PageModel
{
    public async Task OnGetAsync()
    {
        await ExceptionalMiddleware.HandleRequestAsync(HttpContext).ConfigureAwait(false);
    }
}

Here is the error route screen print:

enter image description here

Here is the console log:

enter image description here

Here is my ConfigureServices method:

services.AddExceptional(Configuration.GetSection("Exceptional"), options =>
{
    options.UseExceptionalPageOnThrow = Env.IsDevelopment();
});

Here is my Configure method:

app.UseExceptional();

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
    endpoints.MapRazorPages();
});

I even tried changing the middleware order by placing the app.UseExceptional() after app.UseStaticFiles(). But still it doesn't work. Please assist on why the assets are not getting loaded.

fingers10 avatar Mar 18 '20 18:03 fingers10