This file contains 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 class CustomRequireHttpsFilter : RequireHttpsAttribute | |
{ | |
protected override void HandleNonHttpsRequest(AuthorizationContext filterContext) | |
{ | |
// The base only redirects GET, but we added HEAD as well. This avoids exceptions for bots crawling using HEAD. | |
// The other requests will throw an exception to ensure the correct verbs are used. | |
// We fall back to the base method as the mvc exceptions are marked as internal. | |
if (!String.Equals(filterContext.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase) | |
&& !String.Equals(filterContext.HttpContext.Request.HttpMethod, "HEAD", StringComparison.OrdinalIgnoreCase)) |