增加功能:增加404错误处理
This commit is contained in:
parent
0320b68d5d
commit
4f9894d5bb
|
@ -9,6 +9,7 @@
|
||||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="1.0.0" />
|
<PackageReference Include="Bootstrap.Security.Mvc" Version="1.0.0" />
|
||||||
<PackageReference Include="Longbow.Web" Version="1.0.1" />
|
<PackageReference Include="Longbow.Web" Version="1.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />
|
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -22,11 +22,12 @@ namespace Bootstrap.Admin.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public ActionResult Error()
|
public IActionResult Error(int id)
|
||||||
{
|
{
|
||||||
return View();
|
return id == 404 ? View("NotFound") : View();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -62,6 +62,7 @@ namespace Bootstrap.Admin
|
||||||
{
|
{
|
||||||
app.UseExceptionHandler("/Home/Error");
|
app.UseExceptionHandler("/Home/Error");
|
||||||
}
|
}
|
||||||
|
app.UseStatusCodePagesWithReExecute("/Home/Error/{0}");
|
||||||
app.UseCors(builder => builder.WithOrigins(Configuration["AllowOrigins"].Split(',', StringSplitOptions.RemoveEmptyEntries)).AllowAnyHeader().AllowAnyMethod().AllowCredentials());
|
app.UseCors(builder => builder.WithOrigins(Configuration["AllowOrigins"].Split(',', StringSplitOptions.RemoveEmptyEntries)).AllowAnyHeader().AllowAnyMethod().AllowCredentials());
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
@{
|
||||||
|
ViewBag.Title = "资源未找到";
|
||||||
|
Layout = "~/Views/Shared/_Root.cshtml";
|
||||||
|
}
|
||||||
|
@section css {
|
||||||
|
<link href="~/css/error.css" rel="stylesheet" />
|
||||||
|
}
|
||||||
|
@section Javascript {
|
||||||
|
<script src="~/js/error.js"></script>
|
||||||
|
}
|
||||||
|
<section class="error-wrapper">
|
||||||
|
<img src="~/images/404_icon.png" />
|
||||||
|
<h1>请求资源未找到</h1>
|
||||||
|
<h3>相关错误信息已经记录到日志中,请登录服务器查看</h3>
|
||||||
|
<br />
|
||||||
|
<a href="~/Home/Index" target="_top">返回首页</a>
|
||||||
|
</section>
|
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
Loading…
Reference in New Issue