为什么IIS会突然剥离网页扩展



今天早上,我推出了一个新的.Net网站(更新4.6.1,之前为4.5.1)。IIS(我认为)从所有网页中删除了扩展(即index.aspx刚刚成为索引)。我已经让这些网站使用IIS重写运行了8年多。看起来IIS看到了"无扩展"的网页,重写开始了,并将其发送到一个不存在的位置,生成了404。

我3天前也做了一次Windows更新(从那以后可能会错过这个问题,但可能性不大)。重写规则基本上说,如果找不到页面,请在"Clients"子目录中查找该页面。规则看起来像:

<rewrite>
<rules>
<rule name="Client Relocation" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" negate="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="Clients/{R:0}" />
</rule>
</rules>
</rewrite>

我能够通过删除子目录中的重写规则来解决这个问题:

<rewrite>
<rules>
<remove name="Client Relocation" />
</rules>
</rewrite>

因此,扩展似乎被剥离了,然后IIS获取该页面并认为它不存在,因此重写规则生效。

所以,我的问题是:谁/什么在剥离扩展,我如何阻止它这样做?

Lex Li对应用程序和失败的请求跟踪发表了评论,使我走上了正轨。结果是修改并添加了App_Start/RouteConfig.cs文件:

var settings = new FriendlyUrlSettings();
settings.AutoRedirectMode = RedirectMode.Permanent;
routes.EnableFriendlyUrls(settings);

不完全确定是如何或为什么,但评论掉了AutoRedirectMode将扩展重新打开。如果我能回答Lex的评论,我会的。

最新更新