【问题标题】:URL Rewrite issues on IIS 7.0 with subdomains, not present on IIS 7.5带有子域的 IIS 7.0 上的 URL 重写问题,在 IIS 7.5 上不存在
【发布时间】:2011-10-05 14:37:42
【问题描述】:

我正在构建这个需要几个子域的 asp.net 应用程序。它们都将共享相同的代码库,但我在其自己的子文件夹中为每个子域都有单独的 .aspx,如下所示:

admin.domain.com -> domain.com/admin
user.domain.com -> domain.com/user
...

使用以下重写规则,在我的开发箱(win7、iis 7.5)上一切正常:

<rule name="admin.domain.com" stopProcessing="true">
   <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^admin.domain.com$" />
        <add input="{PATH_INFO}" pattern="^/images/" negate="true" />
        <add input="{PATH_INFO}" pattern="^/handlers/" negate="true" />
        <add input="{PATH_INFO}" pattern="^/aspnet_client/" negate="true" />
        <add input="{PATH_INFO}" pattern="^/webservices/" negate="true" />
        <add input="{URL}" pattern="\.axd$" negate="true" />
      </conditions>
      <action type="Rewrite" url="\admin\{R:0}" />
</rule>

当我在 IIS 7.0 上将我的版本推送到运行 Win 2008 R1 的生产环境时,重写会中断。我看到我在页面源代码中的&lt;form&gt; 标记指向action="admin/",而在7.5 上它指向root。因此,当我发布表单时,我得到 404,因为每次重写都没有 /admin 子文件夹。

我能做些什么来解决这个问题吗?我想省略升级到 R2 来解决这个问题。我可以单独升级 URL 重写模块吗?我可以使用不同的重写规则来解决这个问题吗?

感谢任何帮助!

【问题讨论】:

    标签: asp.net iis url iis-7 url-rewriting


    【解决方案1】:

    我找到了一个解决方案,出于某种原因,在 iis 7.0 上,您必须在定义表单的地方添加以下内容。就我而言,它是我的母版页中的 Page_Load。希望这可以帮助。

    form1.Action = Request.RawUrl
    

    【讨论】:

      猜你喜欢
      • 2011-10-21
      • 1970-01-01
      • 2023-03-08
      • 2015-05-11
      • 2013-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多