23

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.

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
Jason Weber
  • 5,653
  • 6
  • 40
  • 73
  • 3
    possible duplicate of [The element > system.webServer' has invalid child > element 'rewrite'](http://stackoverflow.com/questions/5309059/the-element-system-webserver-has-invalid-child-element-rewrite) – AakashM Feb 14 '12 at 17:00
  • 1
    (there's a further dupe candidate linked from that) – AakashM Feb 14 '12 at 17:00
  • Aakash, I don't se the system.Webserver anywhere else in my web.config file. Should I be looking for something else? – Jason Weber Feb 15 '12 at 06:50
  • 1
    Hmm, looks like it's actually [asp.net, url rewrite module and web.config](http://stackoverflow.com/questions/363231/asp-net-url-rewrite-module-and-web-config) that's the stuff you need. – AakashM Feb 15 '12 at 09:16
  • I mean ... it's working fine on the website; maybe I should just not worry about the error Visual Studio gives me ... Thanks for helping, Aakash! – Jason Weber Feb 15 '12 at 10:01

3 Answers3

22

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.

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
  • 11
    For Visual Studio 2012, use http://blog.vanmeeuwen-online.nl/2013/04/visual-studio-2012-xml-intellisense-for.html instead – Jeow Li Huan Jun 18 '13 at 07:57
0

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

Tested with VS2015 Upgrade 3.

Roland
  • 4,619
  • 7
  • 49
  • 81
0

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