شخصی سازی صفحات خطا در ASP.NET MVC Core
200, OK
https://joonasw.net/view/custom-error-pages icon

Custom error pages in ASP.NET MVC Core


app.Use(async (ctx, next) =>
{
    await next();

    if(ctx.Response.StatusCode == 404 && !ctx.Response.HasStarted)
    {
        //Re-execute the request so the user gets the error page
        string originalPath = ctx.Request.Path.Value;
        ctx.Items["originalPath"] = originalPath;
        ctx.Request.Path = "/error/404";
        await next();
    }
});

 

شخصی سازی صفحات خطا در ASP.NET MVC Core