Skip to content

Instantly share code, notes, and snippets.

@Alxandr
Created December 13, 2014 20:32
Show Gist options
  • Select an option

  • Save Alxandr/df582a764aa736580e50 to your computer and use it in GitHub Desktop.

Select an option

Save Alxandr/df582a764aa736580e50 to your computer and use it in GitHub Desktop.
404 Error page in vNext
app.Use(next => async context =>
{
await next(context);
if(context.Response.ContentLength == null)
{
context.Response.StatusCode = 404;
var path = Path.Combine(_hostingEnvironment.WebRoot, "_error", "404.html");
var content = File.ReadAllText(path);
await context.Response.SendAsync(content, "text/html");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment