Status Code: 404; Not Found
app.UseExceptionHandler("/errors/500");
app.UseStatusCodePagesWithReExecute("/errors/{0}");
public class ErrorsController : Controller
{
[Route("errors/{statusCode}")]
public IActionResult CustomError(int statusCode)
{
if(statusCode == 404)
{
return View("~/Views/Errors/404.cshtml");
}
return View("~/Views/Errors/500.cshtml");
}
}
System.DllNotFoundException: Unable to load DLL 'System.Security.Cryptography.Native.Apple': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
app.UseExceptionHandler(errorApp =>
{
errorApp.Run(async context =>
{
context.Response.StatusCode = 500;
if (context.Request.Headers["X-Requested-With"] != "XMLHttpRequest")
{
context.Response.ContentType = "text/html";
await context.Response.SendFileAsync($@"{env.WebRootPath}/errors/500.html");
}
});
});
app.UseStatusCodePagesWithReExecute("/errors/{0}");
public class ErrorsController : Controller
{
private IHostingEnvironment _env;
public ErrorsController(IHostingEnvironment env)
{
_env = env;
}
[Route("errors/{statusCode}")]
public IActionResult CustomError(int statusCode)
{
var filePath = $"{_env.WebRootPath}/errors/{(statusCode == 404?404:500)}.html";
return new PhysicalFileResult(filePath, new MediaTypeHeaderValue("text/html"));
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有