Created
July 28, 2017 03:45
-
-
Save nbarbettini/01030ef83df9d87452e60c0c65e4cf86 to your computer and use it in GitHub Desktop.
Wire up custom exception handler with IHostingEnvironment in ASP.NET Core 1.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) | |
{ | |
// other code... | |
var hostingEnvironment = app.ApplicationServices.GetRequiredService<IHostingEnvironment>(); | |
app.UseExceptionHandler(new ExceptionHandlerOptions | |
{ | |
ExceptionHandler = new JsonExceptionMiddleware(hostingEnvironment).Invoke | |
}); | |
app.UseMvc(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment