Carolyn Van Slyck

Using both HTTP and HTTPS in ASP.NET MVC

I recently added a secured payment page to my MVC site using the RequireHttps attribute and quickly noticed that once the user went to the page, all other pages were now being served up via https as well. I prefer to only use https when necessary and wanted the user to be redirected back to http for any pages that didn't require https.

Below is the code for my RequireHttp attribute. It can be placed on either a controller or action and will redirect from https to http when necessary.