【发布时间】:2012-03-06 01:15:03
【问题描述】:
对于我在 IIS7 中所做的许多事情,我有许多重写规则,例如删除尾部斜杠、规范 URL、小写字母等。 IIS 更改了我的 web.config,并且网站上的一切正常,就像它应该的那样。但是在 Visual Studio web.config 中,开头的<rewrite> 语句带有蓝色下划线,并且在 VS 的底部,它说 元素 'system.webServer' 具有无效的子元素 'rewrite'。但这就是 IIS 的实现方式......我没有手动执行此操作。我应该关心这个 VS 错误,还是应该保持原样,因为它正在按应有的方式工作?
这是我的 web.config 的一个示例:
<system.webServer>
<rewrite> <-------------------- this is underlined in squiggly blue
<rules>
<rule name="RemoveASPX" enabled="true" stopProcessing="true">
<match url="(.*)\.aspx" />
<action type="Redirect" url="{R:1}" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="(.*)/default.aspx" negate="true" />
<add input="{URL}" pattern="(.*)/admin/*" negate="true" />
<add input="{URL}" pattern="(.*)/desktopmodules/*" negate="true" />
</conditions>
</rule>
还有大约 5 或 6 条其他规则,最后是结束 </system.webServer>。
【问题讨论】:
-
(还有一个与之相关的欺骗候选人)
-
Aakash,我没有在我的 web.config 文件中的任何其他地方看到 system.Webserver。我应该寻找其他东西吗?
-
嗯,看起来实际上是 asp.net, url rewrite module and web.config 这就是你需要的东西。
-
我的意思是......它在网站上运行良好;也许我不应该担心 Visual Studio 给我的错误...感谢 Aakash 的帮助!
标签: asp.net vb.net visual-studio visual-studio-2010 web-config