Created
December 13, 2014 20:32
-
-
Save Alxandr/df582a764aa736580e50 to your computer and use it in GitHub Desktop.
404 Error page in vNext
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
| 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