Last active
October 10, 2017 09:46
-
-
Save vanillajonathan/faf0d87f1f22d85227d1940c2d7122df to your computer and use it in GitHub Desktop.
ASP.NET Core middleware that forbids HTTP requests
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(async (context, next) => | |
{ | |
if (!context.Request.Scheme.IsHttps) { | |
context.Response.StatusCode = StatusCodes.Status403Forbidden; | |
await context.Response.WriteAsync("HTTPS is required."); | |
return; | |
} | |
await next.Invoke(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment