عنوان:

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


نویسنده: جواد غدیری
تاریخ: ۱۳۹۸/۰۴/۰۲ ۱۰:۲۸
آدرس: www.dntips.ir

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();
    }
});

 



مشاهده مطلب اصلی