Asp.net IIS 7中的URL重写导致重定向循环

Asp.net IIS 7中的URL重写导致重定向循环,asp.net,iis,url-rewriting,Asp.net,Iis,Url Rewriting,例如,我尝试了在web上找到的各种方法(包括一些SO答案),以使IIS 7中的URL重写工作正常,从而可以将mysite.com/somepage.aspx转换为mysite.com/somepage。我尝试过的最后一件事是这个链接上的视频:。在IIS中应用这些更改后,我现在可以请求mysite.com/somepage并访问mysite.com/somepage.aspx,同时删除地址栏中的.aspx。部分成功 然而,当我试图直接请求mysite.com/somepage.aspx时,我进入了

例如,我尝试了在web上找到的各种方法(包括一些SO答案),以使IIS 7中的URL重写工作正常,从而可以将mysite.com/somepage.aspx转换为mysite.com/somepage。我尝试过的最后一件事是这个链接上的视频:。在IIS中应用这些更改后,我现在可以请求mysite.com/somepage并访问mysite.com/somepage.aspx,同时删除地址栏中的.aspx。部分成功

然而,当我试图直接请求mysite.com/somepage.aspx时,我进入了一个重定向循环。我希望我的设置中有一些简单的错误。以下是通过在IIS中进行更改而创建的
web.config
部分:

<rewrite>
        <rules>
            <rule name="HideAspxExtension">
                <match url="^(.*)$" />
                <conditions logicalGrouping="MatchAny">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{REQUEST_FILENAME}.aspx" matchType="IsFile" />
                </conditions>
                <action type="Rewrite" url="{R:0}.aspx" />
            </rule>
            <rule name="RedirectingAspxExtension" stopProcessing="true">
                <match url="^(.*).aspx$" />
                <conditions logicalGrouping="MatchAny">
                    <add input="{URL}" pattern="^(.*).aspx$" />
                </conditions>
                <action type="Redirect" url="{R:1}" />
            </rule>
        </rules>
    </rewrite>


我尝试将此设置应用于多个应用程序,得到了相同的结果。我没有另一台服务器来测试。

这些是我以前使用过的规则:

<rule name="StripAspx">
    <match url="^(.+)\.aspx$" />
    <action type="Redirect" url="{R:1}" redirectType="Permanent" />
</rule>
<!-- Rewrite the .aspx for internal processing-->
<rule name="RewriteASPX" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="{R:1}.aspx" />
</rule>

我能看到的主要区别是:

  • 首先删除
    .aspx
    (在重写规则中,顺序问题)。这也意味着在这些规则中,
    stopProcessing
    指令在重写
    .aspx
    上,而不是重定向离开它
  • 这些没有