How do I enable ssl for all controllers in mvc application

前端 未结 2 743
借酒劲吻你
借酒劲吻你 2021-02-13 20:09

I have a MVC 5 app and I installed the ssl certificate and I\'m now connecting with https, but in my code I had to set the \'[requirehttps]\' attribute on the homecontroller lik

2条回答
  •  孤独总比滥情好
    2021-02-13 20:25

    Use the RegisterGlobalFilters method in your FiltersConfig.

    public class FilterConfig
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
            filters.Add(new RequireHttpsAttribute());
        }
    }
    

提交回复
热议问题