MVC RequireHttps entire site

前端 未结 9 1107
遇见更好的自我
遇见更好的自我 2020-12-23 13:24

I have read the previous posts about using the RequireHttpsAttribute to secure individual controllers:

ASP.NET MVC RequireHttps in Production Only

but is the

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-23 13:42

    Just to bring this answer upto date for MVC 3 and above use the following in your Filterconfig.cs file within the App_start folder

            filters.Add(new RequireHttpsAttribute());
    

    Obviously you will need your servers IIS configured to use a valid SSL certificate, cheap certs can be purchased here: https://www.namecheap.com/ i think the last time i purchased one it was $9 per domain per year.

提交回复
热议问题