IIS 默认重定向

发布于 2024-11-30 07:10:20 字数 547 浏览 1 评论 0原文

在IIS7中,如果网站级别的默认重定向是相对路径,如何使默认重定向在https而不是http上。

目前,如果主机是:abc.com 并且登录页面是 abc.com/myapp/login.aspx,我将默认重定向(IIS 管理器 -> HTTPRedirect)设置为 /myapp/login.aspx。因此,如果用户在浏览器地址栏中输入 abc.com,他将被重定向到 http://abc。 com/myapp/login.aspx。我想确保用户被重定向到 http*s*://abc.com/myapp/login.aspx。

它需要根级别的 web.config 吗?

请注意,这不能在 ASP.NET 代码中完成,因为 ASP.NET 代码不参与此请求的处理

编辑: 一种方法是在根(网站)级别部署一个“默认”Web 应用程序,即 Web 应用程序,然后使用 ASP.NET 提供的标准重定向模块。对优点和缺点有什么想法吗?

In IIS7, if the default redirect at the website level is a relative path, how to make the default redirect is on https and not http.

Currently if the host is: abc.com and the login page is abc.com/myapp/login.aspx, I set the default redirect (IIS manager -> HTTPRedirect) to /myapp/login.aspx. So, if the user enters abc.com in his browser address bar, he gets redirected to http://abc.com/myapp/login.aspx. I want to make sure the user gets redirected to http*s*://abc.com/myapp/login.aspx.

Would it need a web.config at the root level?

Note that this cannot be done in asp.net code, because the asp.net code is not involved in the processing of this request

Edit:
One way to do it is having a "default" web app i.e. web app deployed at the root (web site) level and then use the standard redirection module available with asp.net. Any thoughts on pros, cons?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伊面 2024-12-07 07:10:20

最后我们提出了 3 个不同的选项:

  1. 在“网站”级别使用 index.htm 并放置一个 javascript 来设置
    window.location.href 到 https URL。
  2. 使用 IIS URL 重写 模块
  3. 使用自定义 asp.net 模块来重定向到 https URL。该模块的 dll 将在 GAC 中注册,并在“网站”级别配置该模块。在 GAC 中注册是必要的,因为该模块将被“网站”的子应用程序调用。

选择选项 3 的原因是:

  1. 易于部署。在所有前端服务器上安装重写模块比在 GAC
  2. 支持中安装不会解析 javascript 的非浏览器用户代理的 dll 更复杂。这消除了选项 1。

Finally we came up with 3 different options:

  1. Use an index.htm at the "Web Site" level and put a javascript that would set the
    window.location.href to the https URL.
  2. Use the IIS URL rewrite module
  3. Use a custom asp.net module to do the redirection to a https URL. The dll for this module will be registered in GAC and the module configured at the "Web Site" level. The registration in GAC is necessary because the module will be invoked for the child applications of the "Web Site"

The option 3 was selected based on :

  1. Ease of Deployment. Installing the rewrite module on all the front end servers is more complex than installing a dll in GAC
  2. Support for non-browser User Agents that will not parse the javascript. This eliminates option 1.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文