The MVC framework: the RequireSslAttribute
The RequireSslAttribute is a filter attribute which you can apply to a class or method and which is responsible for overriding the OnAuthorization method and seeing if the current request is being done over SSL. The filter exposes a single property, called Redirect.
When it detects that the current request is not under SSL, it checks the Redirect property: if it’s set to true, then it will build an https url based on the current request and redirect the user to that new url; if the Redirect property is set to false, then it will simply throw an exception.
And that’s all there is to know about this attribute. Keep tuned for more on the MVC framework.