Asp.net 从web.config文件重定向url无法正常工作

Asp.net 从web.config文件重定向url无法正常工作,asp.net,iis,url-rewriting,web-config,Asp.net,Iis,Url Rewriting,Web Config,我想删除我的html扩展名,但在目录中执行时失败。 我的网站的一部分工作正常,但其他目录链接工作不正常。 我想删除此链接末尾的html扩展 但是在我重写之后 这是行不通的 在stackover flow中,我找到了问题的解决方案,但它没有正常工作 我在web.config文件中的解决方案是 <rewrite> <rules> <rule name="Hide .html ext"> <match ig

我想删除我的html扩展名,但在目录中执行时失败。 我的网站的一部分工作正常,但其他目录链接工作不正常。

我想删除此链接末尾的html扩展

但是在我重写之后

这是行不通的

在stackover flow中,我找到了问题的解决方案,但它没有正常工作

我在web.config文件中的解决方案是

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

我想你想要的是另一条重写规则。您从
credentialing.html
重定向到
credentialing
,但该文件不存在,因此您可能会收到404。 您需要的是一个规则,该规则再次添加
.html
扩展名作为重写,以便IIS可以再次找到该文件

<rule name="No html ext" stopProcessing="true">
  <match url="^([a-z0-9-_/]+)$" ignoreCase="true" />
  <action type="Rewrite" url="{R:1}.html" />
</rule>