mvc3 https & http

后端 未结 4 883
攒了一身酷
攒了一身酷 2021-01-02 04:05

I am converting an asp.net application into mvc3. Lets say I have a sign in page that requires https and every other page only needs http how can I redirect the signin to ht

4条回答
  •  滥情空心
    2021-01-02 04:41

    I like this solution because: 1. Cause you never have to touch it again in VS. The decorator by itself causes the browser to render the site in https even in debug.

    1. If you implement it into a base controller and have all your controllers inherit from that controller, you know there is no slipping in the back do "So to speak".

      #if !DEBUG
      #define RELEASE
      #endif namespace ProjectName.UI.Controllers {
          using System.Web.Mvc;
          #if RELEASE
              [RequireHttps]
          #endif
          public abstract partial class ProjectNameBaseController : Controller
          {
          } 
      }
      

提交回复
热议问题