To enable https on mvc, one can use the [RequireHttps] attribute on the base controller if you are using a base controller

But what if you want to give an option to the installer or the client to enable it in web.config, the easy way to do it for asp mvc2 is to create your own property like code below: (Please note: I am using protected virtual to override stuff for testing, its not one of the best things but it works in breaking dependency and its quick, so that I dont have to mock httpcontext, configuration manager etc etc, I could use an IoC but would make it more complicated for the reader but feel free to use one)

Here is the unit test for it, I am using a stub class to override the things I want for testing

Now in your web.config you can add a key value pair like

And last if you are using Asp.Net Mvc3 life is way easier, one can just use in their Global.ascx file to add the filter

Lastly you would add it to your BaseController