Startup.cs:
public class Startup
{
public void Configure(IApplicationBuilder app)
{
// PICK YOUR FLAVOR.
// app.UseErrorPage(ErrorPageOptions.ShowAll);
app.UseStatusCodePages(); // There is a default response but any of the following can be used to change the behavior.
// app.UseStatusCodePages(context => context.HttpContext.Response.SendAsync("Handler, status code: " + context.HttpContext.Response.StatusCode, "text/plain"));
// app.UseStatusCodePages("text/plain", "Response, status code: {0}");
// app.UseStatusCodePagesWithRedirects("~/errors/{0}"); // PathBase relative
// app.UseStatusCodePagesWithRedirects("/base/errors/{0}"); // Absolute
// app.UseStatusCodePages(builder => builder.UseWelcomePage());
// app.UseStatusCodePagesWithReExecute("/errors/{0}");
}
}
project.json:
"dependencies": {
"Microsoft.AspNet.Diagnostics": "1.0.0-*",
// ....
}
note that, if you are hosting on IIS (or azure), the web.config
does still works and it's big maybe needed in some hosting scenarios. (it should be placed inside wwwroot
folder
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…