【问题标题】:Element 'system.webServer' has invalid child element 'rewrite'. Should I fix this, and how?元素“system.webServer”具有无效的子元素“rewrite”。我应该解决这个问题,如何解决?
【发布时间】: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 条其他规则,最后是结束 &lt;/system.webServer&gt;

【问题讨论】:

标签: asp.net vb.net visual-studio visual-studio-2010 web-config


【解决方案1】:

这里更新的架构为我解决了这个问题。

http://ruslany.net/2009/08/visual-studio-xml-intellisense-for-url-rewrite-1-1/

确保为 VS2010 更改脚本:

ruslany 于 2009 年 10 月 20 日晚上 7:10 回复#

@Gene: 这是因为 XML 模式缓存位于 VS2010中的不同位置。你能打开 UpdateSchemaCache.js 并替换这一行:

var vs9CommonTools = shell.ExpandEnvironmentStrings(“%VS90COMNTOOLS%” );

用这一行:

var vs9CommonTools = shell.ExpandEnvironmentStrings( “%VS100COMNTOOLS%”);

然后尝试运行脚本,看看是否有帮助。

【讨论】:

【解决方案2】:

VisualStudio 2015 确实支持 &lt;rewrite&gt; 标签,但仅适用于 .Net 4.0 及更高版本。

使用 VS2015 升级 3 测试。

【讨论】:

    【解决方案3】:

    Rewrite 标记是 web.config system.webServer 元素的属性,而不是 system.web 元素的属性。容易出错。

    【讨论】:

      猜你喜欢
      • 2011-07-15
      • 2019-02-18
      • 2016-10-23
      • 1970-01-01
      • 1970-01-01
      • 2020-03-25
      • 2020-02-14
      相关资源
      最近更新 更多