asp.net-mvcsslasp.net-mvc-2httpsasp.net-mvc-futures

ASP.NET MVC RequireHttps


How do I use the ASP.NET MVC 2 Preview 2 Futures RequireHttps attribute?

I want to prevent unsecured HTTP requests from being sent to an action method. I want to automatically redirect to HTTPS.

MSDN:

How do I use this feature?


Solution

  • My guess:

    [RequireHttps] //apply to all actions in controller
    public class SomeController 
    {
      //... or ...
      [RequireHttps] //apply to this action only
      public ActionResult SomeAction()
      {
      }
    
    }