即使 F5 (big-ip) 正在处理 ssl,ASP.NET MVC 3 如何知道在链接上放置 https?
在我们的网站上,我们有 F5 的 Big IP 处理 SSL 加密和解密,并将请求发送到我们服务器上的端口 80。
由于这是我们使用 ASP.NET MVC 制作的第一个网站,我很好奇它将如何处理视图中的 @HTML.ActionLink。令人惊讶的是,它把 https:// 。在我们的 CI 环境(不执行 SSL)上,它会将 http:// 放在所有链接上。
我们还有其他链接来引入 javascript 文件、css 文件和图像,并且我们使用 F5 添加到请求中的自定义 HTTP 标头,以便我们可以判断。
有谁知道 ASP.NET MVC3 如何知道链接是否应该包含 http:// 或 https://,因为我宁愿没有自定义 HTTP 标头进来,如果有一种方法我们可以使用相同的方法。
On our site, we have F5's Big IP handling the SSL encrypting and decryption, and sending the request to port 80 on our server.
Since this is the first site we are doing with ASP.NET MVC, I was curious how it would handle @HTML.ActionLink's in the views. Surpisingly, it is putting https://. On our CI environment (which doesn't do the SSL), it is putting http:// on all the links.
We have other links to bring in javascript files, css files and images, and we are using a custom HTTP header added by F5 to the request so we can tell.
Does anyone know how ASP.NET MVC3 knows whether or not the links should have http:// or https://, as I would rather not have a custom HTTP header coming in, if there is a way we can use the same method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在控制器中使用 RequireHttpsAttribute ,这是一种方法。因为如果使用 Http 调用,它将重定向到 Https。
您的情况可能的另一个重要方式是它使用当前请求路径(Request.AbsoluteUrl)来创建链接,因此,如果使用 HTTPs 调用原始页面,则链接将是 Https (快速查看代码) 。
因此,原始 URL 可能会到达 IIS 的端口 80,但指示该 URL 包含 Https。尝试输出类似
Request.ServerVariables[ "HTTP_URL" ]
的内容进行确认。我假设Request.ServerVariables["HTTPS"]
在您描述的情况下。IF you use
RequireHttpsAttribute
in your controller, this is one way. As it'll redirect to Https if called with Http.Another important way that is likely your case is that it uses the current request path (Request.AbsoluteUrl) to make the links, so, if the original page is called using HTTPs, the links will be Https (from quick look at the code).
So, maybe the raw URL is coming to IIS to port 80 but with indicating that the URL includes Https. Try to output something like
Request.ServerVariables[ "HTTP_URL" ]
to confirm. I assume thatRequest.ServerVariables["HTTPS"]
in your case as you describe it.