Can app.UseErrorHandler() access error details?

前端 未结 3 795
轻奢々
轻奢々 2021-01-02 11:33

In my MVC4 app I had a global.asax.cs override of Application_Error(object sender, EventArgs e) where I could extract the exception, statusCo

3条回答
  •  粉色の甜心
    2021-01-02 12:29

    In Beta8, agua from mars' answer is a little different.

    Instead of:

    var feature = Context.GetFeature();
    

    Use:

    var feature = HttpContext.Features.Get();
    

    This also requires a reference to Microsoft.AspNet.Http.Features, and the following line in Configure() in Startup.cs:

    app.UseExceptionHandler("/Home/Error");
    

提交回复
热议问题