我尝试在.NET Core 2.1项目中使用StackExchange.Exceptional。 我没有说明他们的文档访问错误的URL。 我尝试使用谷歌解决方案,但只有我能找到的是ASP.NET MVC 5项目的旧URL,这是主页/错误 在.NET Core中不起作用。 有帮助吗?
答案 0 :(得分:0)
据我所知,没有默认路由。 您可以配置一条路线,并将其命名为任意名称。
(develop) $ git about
(develop) $ git about message
(develop) $ git about
message
(develop) $ git about "this is a new message"
(develop) $ git about
this is a new message
您可以做的另一件事是在public sealed class ErrorController : ControllerBase
{
// route will be /exceptions
public async Task Exceptions() => await ExceptionalMiddleware.HandleRequestAsync(HttpContext);
}
的{{1}}方法上进行设置。
Configure
要使其外观更好,您可以在另一个类中添加配置,然后将其导入到您Startup class
// route will be /exceptions
app.UseExceptional();
app.Map(new PathString("/exceptions"), action => action.Use(async (context, next) =>
{
await ExceptionalMiddleware.HandleRequestAsync(context);
}));
app.UseMvc();