asp.net - 元素 > system.webServer' 有无效的子元素 > 元素 'rewrite'

标签 asp.net url-rewriting

Warning 1 The element 'system.webServer' has invalid child element 'rewrite'. List of possible elements expected: 'asp, caching, cgi, defaultDocument, directoryBrowse, globalModules, handlers, httpCompression, httpErrors, httpLogging, httpProtocol, httpRedirect, httpTracing, isapiFilters, modules, odbcLogging, security, serverRuntime, serverSideInclude, staticContent, tracing, urlCompression, validation, management'. D:\PROJEKTI\FoodOrder\FoodOrder\Web.config 185 4 FoodOrder



代码:
system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true">
            <remove name="ScriptModule" />
            <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </modules>
        <handlers>
            <remove name="WebServiceHandlerFactory-Integrated" />
            <remove name="ScriptHandlerFactory" />
            <remove name="ScriptHandlerFactoryAppServices" />
            <remove name="ScriptResource" />
            <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </handlers>
        <rewrite>
            <rewriteMaps>
                <rewriteMap name="StaticRewrites">
                    <!--<add key="/Default.aspx" value="/Default.aspx" />-->
                </rewriteMap>
            </rewriteMaps>
            <rules>

页面有效,但我总是收到警告,当我发布页面时,我收到发布错误,因为这个......

最佳答案

asp.net, url rewrite module and web.config 的可能重复项

当 Visual Studio IntelliSense 在架构文件上找不到有关重写模块的信息时,就会发生这种情况。因此,我们需要在文件中专门为重写部分添加架构:DotNetConfig.xsd

Ruslan 为重写提供了非官方的模式。对于 Visual Studio 2010,请从他的页面下载 xml 架构:http://ruslany.net/2010/04/visual-studio-xml-intellisense-for-url-rewrite-2-0/

从这里下载早期版本:
http://ruslany.net/2009/08/visual-studio-xml-intellisense-for-url-rewrite-1-1/#comment-1402

对于这两个版本,说明是 here .

对于 VS2010 记得替换 %VS90COMNTOOLS%%VS100COMNTOOLS%
对于 VS2012 及更高版本,请关注 fftsys's article .

如果您不想使用 ruslany 的脚本,您仍然可以使用 rewrite 模块。在这种情况下,您仍然可以修改 web.config 以在 Visual Studio 之外添加重写部分。

IIS 的原始重写模块来自 Microsoft:http://www.iis.net/downloads/microsoft/url-rewrite并得到他们的支持。 ruslany 的脚本只是在 Visual Studio 中启用支持,以便 VS 识别它。

关于asp.net - 元素 > system.webServer' 有无效的子元素 > 元素 'rewrite',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5309059/

相关文章:

c# - 进行异步工作以返回快速响应的最佳方法

asp.net - 如何安全地获取正在运行的 ASP.NET 站点的域名

c# - 如何让 WebAPI 使用 JsonProperty(Required = Required.Always) 验证我的 JSON?

asp.net - 在 ASP.NET MVC 4 中,子文件夹中的 _viewStart 文件是附加的还是单独的?

.htaccess - 仅针对一个目录删除带有 .htaccess 的 .php 扩展名?

javascript - Angular module.run ReferenceError : $location is not defined

c# - 如何使用Windows Azure实现URL重写?

c# - 如何使用 C# 代码填充引导模式?

php - HTML 包括使用 PHP 的 CSS

url-rewriting - 当反向代理 301 重定向时,URL 重写保留原始主机位置