在 ASP.NET 中选择性地将 HTTP 请求重定向到 HTTPS 请求
有选择地将 ASP.NET 页面的 HTTP 请求重定向到其 HTTPS 等效项的最简单且最有效的方法是什么?
例如,如果我的页面站点 URL 是 http://www.somesite.com,我想重定向一些(或所有)页面请求 https://www.somesite.com。
最简单的方法是什么?
What's the simplest and most effective way to selectively redirect HTTP requests to your ASP.NET page to its HTTPS equivalent?
For example, if my page site URL is http://www.somesite.com, I want to redirect some (or all) page requests to https://www.somesite.com.
What's the easiest way to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用这段代码来做到这一点。
http://www.codeproject.com/KB/web-security/WebPageSecurity_v2。 aspx
我想说,唯一的缺点是没有使用“正则表达式模式匹配”,但将其添加到代码中非常容易。
I use this code to do that.
http://www.codeproject.com/KB/web-security/WebPageSecurity_v2.aspx
I like to say, that the only minus is that is not use "Regular expression pattern matching", but it was very easy to add it on the code.
取决于您使用的 IIS 版本、您是否有权访问它以及您是否想要编写自定义代码或配置产品功能。
IIS5、IIS6:
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
IIS7、IIS7.5:
URL 重写:
http://learn.iis.net/page .aspx/460/using-the-url-rewrite-module/
以下是重定向规则的示例 http://.../checkout.aspx 到 https:
ASP.NET 路由:
http://msdn.microsoft.com/en-us/library/cc668201.aspx
IIS7,7.5重写与ASP.NET路由的区别
http://learn.iis.net/page.aspx/496/iis-url -重写和-aspnet-路由/
Depending on what version of IIS you are using and whether you have access to it and whether you want to write custom code or configure a product feature.
IIS5, IIS6:
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
IIS7, IIS7.5:
URL Rewrite:
http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/
Here's an example of a rule to redirect http://.../checkout.aspx to https:
ASP.NET Routing:
http://msdn.microsoft.com/en-us/library/cc668201.aspx
Difference between IIS7,7.5 rewrite and ASP.NET routing
http://learn.iis.net/page.aspx/496/iis-url-rewriting-and-aspnet-routing/