Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Last active Mar 23, 2016
Embed
What would you like to do?
ASP.NET Core Tips & Tricks
app.UseExceptionHandler(
builder =>
{
builder.Run(
async context =>
{
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
context.Response.ContentType = "text/html";
var error = context.Features.Get<IExceptionHandlerFeature>();
if (error != null)
{
await context.Response.WriteAsync($"<h1>Error: {error.Error.Message}</h1>").ConfigureAwait(false);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment