Jason Weber
Jason Weber

Reputation: 5741

Element 'system.webServer' has invalid child element 'rewrite'. Should I fix this, and how?

I have a number of rewrite rules for a lot of things that I did in IIS7, like removing trailing slashes, canonnical URLs, lowercase lettering, and such. IIS altered my web.config, and everything works fine on the website, like it should. But in the Visual Studio web.config, the opening <rewrite> statement is underlined in blue, and at the bottom of VS, it says that the element 'system.webServer' has invalid child element 'rewrite'. But this is how IIS made it ... I didn't do this manually. Should I be concerned with this VS error, or should I just leave as be, since it's working how it should work?

Here's an example of my 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>

There are about 5 or 6 other rules, then a closing </system.webServer> at the end.

Upvotes: 23

Views: 30953

Answers (3)

James Dickinson
James Dickinson

Reputation: 11

The Rewrite tag is a property of the web.config system.webServer element not the system.web element. Easy mistake.

Upvotes: 0

Roland
Roland

Reputation: 5234

VisualStudio 2015 does support the <rewrite> tag, but only for .Net versions 4.0 and up.

Tested with VS2015 Upgrade 3.

Upvotes: 0

GEOCHET
GEOCHET

Reputation: 21323

The updated schema here fixed this for me.

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

Make sure you change the script for VS2010:

ruslany responded on 20 Oct 2009 at 7:10 pm #

@Gene: This is be because the XML schema cache is located in a different location in VS2010. Can you open the UpdateSchemaCache.js and replace this line:

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

with this line:

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

After that try running the script and see if that helps.

Upvotes: 22

Related Questions