MVC .NET SSL/https website: [Authorize] redirecting using http (NOT https) to login page

别来无恙 提交于 2019-12-12 04:59:49

问题


My website uses MVC ASP.NET and Entity Framework user roles. The website also requires SSL for every page access by design. Thus, call the site example.com which can only be accessed as "https://example.com" or "https://www.example.com". Port 80 is configured to never respond. All pages work fine, except a main page link which can only be accessed when a user is already logged in. If the user is not logged in yet, moving the cursor over the link shows an https:... prefix is assumed to that link, but the [Authorize] attribute specified in the C# code at the top of the MVC controller action causes redirection to the login page without an https:// prefix. Rather than redirecting to https://example.com/..., redirection goes to example.com/... thereby leaving out the https prefix and causing a hang to the site that requires SSL for all pages.

来源:https://stackoverflow.com/questions/46500783/mvc-net-ssl-https-website-authorize-redirecting-using-http-not-https-to-lo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!