开发者

<rewrite> not a valid child of <system.web>?

开发者 https://www.devze.com 2023-01-19 06:29 出处:网络
Hopefully I am just overlooking something incredibly simple, if so I apologize.... I have an ASP.NET application in .NET4 and we\'re trying to use URL rewriting using

Hopefully I am just overlooking something incredibly simple, if so I apologize....

I have an ASP.NET application in .NET4 and we're trying to use URL rewriting using

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule....>

For some reason intellisense is returning an error which says that <rewrite> is not a valid child element of <system.webserver>

When I build it and run it, it says something akin to "Error at line 0 in web.config"

If I remove all the <rewrite> lines it works properly (but of course no rewriting)

Is there a switch I need to flip on or something? It has to be something I'm stupidl开发者_StackOverflow社区y overlooking....

Thanks

EDIT: Turned out IIS was borked. Vote to close.


Did you make sure you're targeting Framework 4.0?

<compilation targetFramework="4.0"/>


maybe this helps: http://weblogs.asp.net/owscott/archive/2010/06/04/visual-studio-intellisense-for-url-rewrite.aspx


Do you have URL Rewrite module installed on your IIS?


Update DotNetConfig under C:\Program Files (x86)\Microsoft Visual Studio 11.0\Xml\Schemas\1033 , If you are using VS2012 and above.

Open DotnetConfig under notepad++, find keyword System.webServer.

Paste following XML under System.webServer Tag. I have added screenshots,where to update this xml element and save this file.(Remember: Add this to after caching element closed tag)

Note: If it will work(hope so) please Vote this up for other people.

<rewrite> not a valid child of <system.web>?

<!-- language: lang-xml -->
    <xs:element name="rewrite" vs:help="configuration/system.webServer/rewrite">
        <xs:complexType>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element name="globalRules" vs:help="configuration/system.webServer/rewrite/globalRules">
                    <xs:complexType>
                        <xs:choice minOccurs="0" maxOccurs="unbounded">
                            <xs:element name="rule" vs:help="configuration/system.webServer/rewrite/globalRules/rule">
                                <xs:complexType>
                                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                                        <xs:element name="match" vs:help="configuration/system.webServer/rewrite/globalRules/rule/match">
                                            <xs:complexType>
                                                <xs:attribute name="url" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/match/url">
                                                    <xs:simpleType>
                                                        <xs:restriction base="xs:string">
                                                            <xs:minLength value="1" />
                                                        </xs:restriction>
                                                    </xs:simpleType>
                                                </xs:attribute>
                                                <xs:attribute name="negate" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/match/negate" />
                                                <xs:attribute name="ignoreCase" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/match/ignoreCase" />
                                            </xs:complexType>
                                        </xs:element>
                                        <xs:element name="conditions" vs:help="configuration/system.webServer/rewrite/globalRules/rule/conditions">
                                            <xs:complexType>
                                                <xs:choice minOccurs="0" maxOccurs="unbounded">
                                                    <xs:element name="add" vs:help="configuration/system.webServer/rewrite/globalRules/rule/conditions/add">
                                                        <xs:complexType>
                                                            <xs:attribute name="input" type="xs:string" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/conditions/add/input" />
                                                            <xs:attribute name="matchType" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/conditions/add/matchType">
                                                                <xs:simpleType>
                                                                    <xs:restriction base="xs:NMTOKEN">
                                                                        <xs:enumeration value="Pattern" />
                                                                    </xs:restriction>
                                                                </xs:simpleType>
                                                            </xs:attribute>
                                                            <xs:attribute name="negate" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/conditions/add/negate" />
                                                            <xs:attribute name="pattern" type="xs:string" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/conditions/add/pattern" />
                                                            <xs:attribute name="ignoreCase" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/conditions/add/ignoreCase" />
                                                        </xs:complexType>
                                                    </xs:element>
                                                </xs:choice>
                                                <xs:attribute name="logicalGrouping" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/conditions/logicalGrouping">
                                                    <xs:simpleType>
                                                        <xs:restriction base="xs:NMTOKEN">
                                                            <xs:enumeration value="MatchAll" />
                                                            <xs:enumeration value="MatchAny" />
                                                        </xs:restriction>
                                                    </xs:simpleType>
                                                </xs:attribute>
                                            </xs:complexType>
                                        </xs:element>
                                        <xs:element name="action" vs:help="configuration/system.webServer/rewrite/globalRules/rule/action">
                                            <xs:complexType>
                                                <xs:attribute name="type" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/action/type">
                                                    <xs:simpleType>
                                                        <xs:restriction base="xs:NMTOKEN">
                                                            <xs:enumeration value="None" />
                                                            <xs:enumeration value="Rewrite" />
                                                            <xs:enumeration value="Redirect" />
                                                            <xs:enumeration value="CustomResponse" />
                                                            <xs:enumeration value="AbortRequest" />
                                                        </xs:restriction>
                                                    </xs:simpleType>
                                                </xs:attribute>
                                                <xs:attribute name="url" type="xs:string" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/action/url" />
                                                <xs:attribute name="appendQueryString" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/action/appendQueryString" />
                                                <xs:attribute name="redirectType" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/action/redirectType">
                                                    <xs:simpleType>
                                                        <xs:restriction base="xs:NMTOKEN">
                                                            <xs:enumeration value="Permanent" />
                                                            <xs:enumeration value="Found" />
                                                            <xs:enumeration value="SeeOther" />
                                                            <xs:enumeration value="Temporary" />
                                                        </xs:restriction>
                                                    </xs:simpleType>
                                                </xs:attribute>
                                                <xs:attribute name="statusCode" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/action/statusCode" />
                                                <xs:attribute name="subStatusCode" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/action/subStatusCode" />
                                                <xs:attribute name="statusReason" type="xs:string" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/action/statusReason" />
                                                <xs:attribute name="statusDescription" type="xs:string" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/action/statusDescription" />
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:choice>
                                    <xs:attribute name="name" type="xs:string" use="required" vs:help="configuration/system.webServer/rewrite/globalRules/rule/name" />
                                    <xs:attribute name="enabled" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/enabled" />
                                    <xs:attribute name="patternSyntax" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/patternSyntax">
                                        <xs:simpleType>
                                            <xs:restriction base="xs:NMTOKEN">
                                                <xs:enumeration value="ECMAScript" />
                                                <xs:enumeration value="Wildcard" />
                                            </xs:restriction>
                                        </xs:simpleType>
                                    </xs:attribute>
                                    <xs:attribute name="stopProcessing" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/globalRules/rule/stopProcessing" />
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="remove" vs:help="configuration/system.webServer/rewrite/globalRules/rule">
                              <xs:complexType>
                                <xs:attribute name="name" type="xs:string" use="required" vs:help="configuration/system.webServer/rewrite/globalRules/rule/name" />
                              </xs:complexType>
                            </xs:element>
                            <xs:element name="clear" vs:help="configuration/system.webServer/rewrite/globalRules/rule" />
                        </xs:choice>
                    </xs:complexType>
                </xs:element>
                <xs:element name="rules" vs:help="configuration/system.webServer/rewrite/rules">
                    <xs:complexType>
                        <xs:choice minOccurs="0" maxOccurs="unbounded">
                            <xs:element name="rule" vs:help="configuration/system.webServer/rewrite/rules/rule">
                                <xs:complexType>
                                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                                        <xs:element name="match" vs:help="configuration/system.webServer/rewrite/rules/rule/match">
                                            <xs:complexType>
                                                <xs:attribute name="url" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/match/url">
                                                    <xs:simpleType>
                                                        <xs:restriction base="xs:string">
                                                            <xs:minLength value="1" />
                                                        </xs:restriction>
                                                    </xs:simpleType>
                                                </xs:attribute>
                                                <xs:attribute name="negate" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/match/negate" />
                                                <xs:attribute name="ignoreCase" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/match/ignoreCase" />
                                            </xs:complexType>
                                        </xs:element>
                                        <xs:element name="conditions" vs:help="configuration/system.webServer/rewrite/rules/rule/conditions">
                                            <xs:complexType>
                                                <xs:choice minOccurs="0" maxOccurs="unbounded">
                                                    <xs:element name="add" vs:help="configuration/system.webServer/rewrite/rules/rule/conditions/add">
                                                        <xs:complexType>
                                                            <xs:attribute name="input" type="xs:string" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/conditions/add/input" />
                                                            <xs:attribute name="matchType" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/conditions/add/matchType">
                                                                <xs:simpleType>
                                                                    <xs:restriction base="xs:NMTOKEN">
                                                                        <xs:enumeration value="Pattern" />
                                                                        <xs:enumeration value="IsFile" />
                                                                        <xs:enumeration value="IsDirectory" />
                                                                    </xs:restriction>
                                                                </xs:simpleType>
                                                            </xs:attribute>
                                                            <xs:attribute name="negate" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/conditions/add/negate" />
                                                            <xs:attribute name="pattern" type="xs:string" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/conditions/add/pattern" />
                                                            <xs:attribute name="ignoreCase" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/conditions/add/ignoreCase" />
                                                        </xs:complexType>
                                                    </xs:element>
                                                </xs:choice>
                                                <xs:attribute name="logicalGrouping" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/conditions/logicalGrouping">
                                                    <xs:simpleType>
                                                        <xs:restriction base="xs:NMTOKEN">
                                                            <xs:enumeration value="MatchAll" />
                                                            <xs:enumeration value="MatchAny" />
                                                        </xs:restriction>
                                                    </xs:simpleType>
                                                </xs:attribute>
                                            </xs:complexType>
                                        </xs:element>
                                        <xs:element name="action" vs:help="configuration/system.webServer/rewrite/rules/rule/action">
                                            <xs:complexType>
                                                <xs:attribute name="type" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/action/type">
                                                    <xs:simpleType>
                                                        <xs:restriction base="xs:NMTOKEN">
                                                            <xs:enumeration value="None" />
                                                            <xs:enumeration value="Rewrite" />
                                                            <xs:enumeration value="Redirect" />
                                                            <xs:enumeration value="CustomResponse" />
                                                            <xs:enumeration value="AbortRequest" />
                                                        </xs:restriction>
                                                    </xs:simpleType>
                                                </xs:attribute>
                                                <xs:attribute name="url" type="xs:string" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/action/url" />
                                                <xs:attribute name="appendQueryString" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/action/appendQueryString" />
                                                <xs:attribute name="redirectType" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/action/redirectType">
                                                    <xs:simpleType>
                                                        <xs:restriction base="xs:NMTOKEN">
                                                            <xs:enumeration value="Permanent" />
                                                            <xs:enumeration value="Found" />
                                                            <xs:enumeration value="SeeOther" />
                                                            <xs:enumeration value="Temporary" />
                                                        </xs:restriction>
                                                    </xs:simpleType>
                                                </xs:attribute>
                                                <xs:attribute name="statusCode" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/action/statusCode" />
                                                <xs:attribute name="subStatusCode" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/action/subStatusCode" />
                                                <xs:attribute name="statusReason" type="xs:string" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/action/statusReason" />
                                                <xs:attribute name="statusDescription" type="xs:string" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/action/statusDescription" />
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:choice>
                                    <xs:attribute name="name" type="xs:string" use="required" vs:help="configuration/system.webServer/rewrite/rules/rule/name" />
                                    <xs:attribute name="enabled" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/enabled" />
                                    <xs:attribute name="patternSyntax" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/patternSyntax">
                                        <xs:simpleType>
                                            <xs:restriction base="xs:NMTOKEN">
                                                <xs:enumeration value="ECMAScript" />
                                                <xs:enumeration value="Wildcard" />
                                            </xs:restriction>
                                        </xs:simpleType>
                                    </xs:attribute>
                                    <xs:attribute name="stopProcessing" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/rules/rule/stopProcessing" />
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="remove" vs:help="configuration/system.webServer/rewrite/rules/rule">
                                <xs:complexType>
                                    <xs:attribute name="name" type="xs:string" use="required" vs:help="configuration/system.webServer/rewrite/rules/rule/name" />
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="clear" vs:help="configuration/system.webServer/rewrite/rules/rule" />
                        </xs:choice>
                    </xs:complexType>
                </xs:element>
                <xs:element name="rewriteMaps" vs:help="configuration/system.webServer/rewrite/rewriteMaps">
                    <xs:complexType>
                        <xs:choice minOccurs="0" maxOccurs="unbounded">
                            <xs:element name="rewriteMap" vs:help="configuration/system.webServer/rewrite/rewriteMaps/rewriteMap">
                                <xs:complexType>
                                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                                        <xs:element name="add" vs:help="configuration/system.webServer/rewrite/rewriteMaps/rewriteMap/add">
                                            <xs:complexType>
                                                <xs:attribute name="key" type="xs:string" use="required" vs:help="configuration/system.webServer/rewrite/rewriteMaps/rewriteMap/add/key" />
                                                <xs:attribute name="value" type="xs:string" use="optional" vs:help="configuration/system.webServer/rewrite/rewriteMaps/rewriteMap/add/value" />
                                            </xs:complexType>
                                        </xs:element>
                                        <xs:element name="remove" vs:help="configuration/system.webServer/rewrite/rewriteMaps/rewriteMap/add">
                                            <xs:complexType>
                                                <xs:attribute name="key" type="xs:string" use="required" vs:help="configuration/system.webServer/rewrite/rewriteMaps/rewriteMap/add/key" />
                                            </xs:complexType>
                                        </xs:element>
                                        <xs:element name="clear" vs:help="configuration/system.webServer/rewrite/rewriteMaps/rewriteMap/add">
                                            <xs:complexType>
                                                <!--tag is empty-->
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:choice>
                                    <xs:attribute name="name" type="xs:string" use="required" vs:help="configuration/system.webServer/rewrite/rewriteMaps/rewriteMap/name" />
                                    <xs:attribute name="defaultValue" type="xs:string" use="optional" vs:help="configuration/system.webServer/rewrite/rewriteMaps/rewriteMap/defaultValue" />
                                    <xs:attribute name="ignoreCase" type="small_boolean_Type" use="optional" vs:help="configuration/system.webServer/rewrite/rewriteMaps/rewriteMap/ignoreCase" />
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="remove" vs:help="configuration/system.webServer/rewrite/rewriteMaps/rewriteMap">
                                <xs:complexType>
                                    <xs:attribute name="name" type="xs:string" use="required" vs:help="configuration/system.webServer/rewrite/rewriteMaps/rewriteMap/name" />
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="clear" vs:help="configuration/system.webServer/rewrite/rewriteMaps/rewriteMap" />
                        </xs:choice>
                    </xs:complexType>
                </xs:element>
            </xs:choice>
        </xs:complexType>
    </xs:element>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号