Sunday, January 30, 2011

Design an Attribute that forces an unsecured HTTP request to be sent over HTTPS in ASP.NET MVC


[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class SampleRequireSSL : RequireHttpsAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
if (Sample.Web.Areas.Admin.Helpers.ConfigSettings.RequireSSL)
{
base.OnAuthorization(filterContext);
}
}
}

No comments:

Post a Comment