How can I configure my ASP.NET MVC 3 application to use HTTP on login and HTTPS on the rest of the pages?
Now I configured the app to use HTTPS on every page including Login.
Does anyone have any suggestions?
Thanks a lot.
Jeff
How can I configure my ASP.NET MVC 3 application to use HTTP on login and HTTPS on the rest of the pages?
Now I configured the app to use HTTPS on every page including Login.
Does anyone have any suggestions?
Thanks a lot.
Jeff
You can use the built-in RequireHttpsAttribute see the documentation reference
You can set this on your controller class like this:
[RequireHttps]
public Controller HomeController() { }
All actions of this controller will use Https.
Or directly on a controller action
[RequireHttps]
public ActionResult Index() { }
You may also register this for the entire app on your global.asax
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new RequireHttpsAttribute());
}