如何在 ASP.NET MVC 中执行 [RequireHttps(Redirect=true)] 的相反操作
我知道在 ASP.NET MVC 中访问 SSL 页面的简单方法 - 通过 [RequireSSL] 属性,但我对执行相反操作的最佳方法有点困惑。
我的网站上的标题栏中有许多链接,其中大多数链接不需要 SSL,而且我不想仍然使用 SSL。
futures 项目可以很容易地使用 [RequireSSL(Redirect=true)]
自动重定向到 SSL 页面,但似乎并不容易脱离此上下文并自动重定向回http。
我缺少什么?
I know the easy way to get to an SSL page in ASP.NET MVC - via the [RequireSSL] attribute but I'm a little confused to the best way to do the opposite.
I have many links on my site in a header bar and most of those links don't require SSL and I don't want to still use SSL.
The futures project makes it very easy to redirect automatically to an SSL page with [RequireSSL(Redirect=true)]
, but it doesnt seem to make it easy to get out of this context and automatically redirect back to http.
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你没有遗漏任何东西; 对此没有开箱即用的功能。 您可以通过RequireSslAttribute 源并修改它来轻松创建自己的属性。
You're not missing anything; there is no out-of-the-box functionality for this. You can easily create your own by taking the RequireSslAttribute source and modifying it.
来自其他地方的欺骗问题的回答:
如何在 asp.net mvc 中从 https 退出到 http 模式。
注意:如果选择使用此方法,您的身份验证 cookie 将在切换回 HTTP 后通过纯文本发送,并且可能被其他人窃取和使用。 查看此内容。 换句话说 - 如果您将其用于银行网站,您需要确保切换到 http 会首先使用户注销。
Answer from a dupe question elsewhere:
How to step out from https to http mode in asp.net mvc.
CAUTION: If choosing to use this approach your auth cookie will be sent over plain text after switching back to HTTP, and can potentially be stolen and used by someone else. See this. In other words - if you were using this for a bank site you would need to make sure that switching to http would first log the user out.
这是非常值得一读的(特别是要认识到不小心从
https
切换回http
的安全隐患:使用 ASP.NET 的部分 SSL 安全 Web 应用 - 不是 MVC 特定的,但相关的安全问题
部分 SSL 网站ASP.NET MVC - MVC 友好
总的来说,这是一个相当复杂的问题,仍然没有找到我想做的所有事情的真正解决方案,但认为这些文章可能对其他人有帮助。
This is well worth reading (epecially to realize the security implications of switching carelessly back to
http
fromhttps
:Partially SSL Secured Web Apps With ASP.NET - not MVC specific but relevant security concerns
Partial SSL Website with ASP.NET MVC - MVC friendly
It's quite a complicated issue overall. Still haven't found a true solution to everything I want to do, but thought these articles may help others.