Visual Studio XML IntelliSense for URL Rewrite 1.1

If you ever tried to write or modify rewrite rules in web.config file by using Visual Studio 2008 XML Editor, you may have noticed that the Visual Studio XML IntelliSense does not work for all URL Rewrite Module configuration elements. This is because the XML schema for <rewrite> element is not registered in Visual Studio Schema Cache. This post provides the instructions on how to register URL Rewrite schema with Visual Studio to enable IntelliSense support.

To enable IntelliSense support for URL Rewrite 1.1 follow these steps:

Step 1: Download the URL Rewrite schema from the location below:

VS IntelliSense for URL Rewrite

Disclaimer: The schema file and the helper script file contained in this package are provided by me and not by Microsoft. The are not officially supported by Microsoft. Use them at your own risk.

Step 2: Extract the content of the file to a directory of your choice, for example C:\rewrite_vsintellisense\

Step 3: Start the elevated privilege command line window by typing “cmd” in the search bar of the Windows Start Menu and then right clicking the “cmd” item in the search result and selecting “Run As Administrator”.

Step 4: In the command line window type the following:

cd \rewrite_intellisense

Replace the path if you unpacked the files into a different location

cscript UpdateSchemaCache.js

You should see the output as below:

Run the UpdateSchemaCache.js

Check that the XML IntelliSense in Visual Studio XML editor works now:

 Intellisense for URL Rewrite Configuration in Visual Studio

In case you want to restore back the original XML schema used by Visual Studio, here is how you can do it:

cd “%ProgramFiles%\Microsoft Visual Studio 9.0\Xml\Schemas"
move DotNetConfig_beforeRewrite.xsd DotNetConfig.xsd

45,401 views

ruslany on August 13th 2009 in URLRewrite

PoorFairAverageGoodExcellent (10 votes, average: 4.30 out of 5)

29 Responses to “Visual Studio XML IntelliSense for URL Rewrite 1.1”

  1. Gravatar ImageDotNetShoutout responded on 18 Aug 2009 at 8:43 am #

    Visual Studio XML IntelliSense for URL Rewrite 1.1 | RuslanY Blog…

    Thank you for submitting this cool story – Trackback from DotNetShoutout…

  2. Gravatar ImageGene responded on 20 Oct 2009 at 1:54 pm #

    The same issue exists in Visual Studio 2010, but after running the script, no love. Is there an updated version for VS 2010?

  3. Gravatar Imageruslany 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.

  4. Gravatar ImageDavid responded on 28 Jan 2010 at 8:02 am #

    The download link doesn’t work for the schema file. Do you have an updated schema for version 2?

  5. Gravatar Imageruslany responded on 28 Jan 2010 at 10:06 am #

    @David: The links should work now. There was some glitch in the WP download plugin.

    I do not yet have a schema for v2.0. I will try to provide it sometime soon.

  6. Gravatar ImageBarbaros responded on 22 Apr 2010 at 2:16 am #

    Any news for v2.0 schema?

  7. Gravatar ImageRuslanY Blog responded on 23 Apr 2010 at 1:50 pm #

    Visual Studio XML IntelliSense for URL Rewrite 2.0…

    Last year I published an XML schema for URL Rewrite 1.1 that could be used to enable IntelliSense support when editing rewrite rules in Visual Studio XML editor. Now that the URL Rewrite 2.0 has been released, the old schema will not work for the the n…

  8. Gravatar Imageruslany responded on 23 Apr 2010 at 1:51 pm #

    @Barbaros: use the link in the trackback above to get the schema for v2.0.

  9. Gravatar ImageVisual Studio IntelliSense for URL Rewrite - Scott Forsyth's Blog responded on 04 Jun 2010 at 6:47 am #

    [...] has released a Visual Studio schema update for URL Rewrite which is available as a free quick download.  Contrary to the title of the post, the installer [...]

  10. Gravatar ImageKirk responded on 14 Jun 2010 at 4:06 am #

    Thanks for posting the update js for vs 2010 install. Works great. Thanks.

  11. Gravatar Image9h0s7 responded on 25 Jun 2010 at 7:50 am #

    I had to add the node to DotNetConfig35.xsd instead of DotNetConfig.xsd on VS 2010 and .net 4

  12. Gravatar ImageDavid Bauernschmidt responded on 24 Sep 2010 at 4:59 pm #

    thank you…This worked great for both VS2008 and vs2010

  13. Gravatar ImageNeil Gibbons responded on 03 Mar 2011 at 7:24 am #

    Great stuff!

    I also added the “logRewrittenUrl” attribute to the XSD. I just copied the “appendQueryString” and changed the name.

    [The xml code has been removed because it was not XML encoded]

    It needs to appear twice, once for globalRules and once for rules elements.

    Cheers

  14. Gravatar ImageRon Clabo responded on 05 Oct 2011 at 8:46 am #

    RuslanY – Thanks for providing the solution to this, especially the comment about how to tweak the file for VS2010. You’re awesome!

    -Ron

  15. Gravatar ImageDean responded on 10 Feb 2012 at 2:57 pm #

    Great job, worked for 2008 and 2010, thanks

  16. Gravatar ImageSam responded on 27 Feb 2012 at 1:13 pm #

    Thank goodness that 9h0s7 put down the comment that it should be added to DotNetConfig35.xsd for VS10 and .NET Framework 4. Otherwise, this solution would have been no solution at all for me.

  17. Gravatar ImageAmerico responded on 16 May 2012 at 8:13 am #

    Before you run the script, make sure that your windows environment variables has…

    VS100COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\

    To view your envionment variables, open a command prompt and type the command “SET”

  18. Gravatar ImageKlaus Jensen responded on 25 Jul 2012 at 11:55 am #

    It worked like a charm in VS2010 after updating the “90″ to “100″ in the javascript. Thanks!

    The things we do to get rid of a squiggly line… :)

  19. Gravatar ImageBrant Burnett responded on 19 Oct 2012 at 11:40 am #

    Got it working in VS2012. First change “90″ to “110″ in the javascript. Then add “1033\” to the end of the path where it is assigning the dotNetSchemaDir variable. On my computer, the file that should be affected was in the C:Program Files (x86)Microsoft Visual Studio 11.0XmlSchemas1033 folder.

  20. Gravatar ImagePrasad responded on 25 Dec 2012 at 3:45 am #

    worked like a charm, thanks

  21. Gravatar ImageBill H responded on 17 Jan 2013 at 2:54 pm #

    Successfully added 2.0 to VS2012, I can browse dotnetconfig.xsd and rewrite is there, but VS still remarks invalid child element, even after restart. Any suggestions?

    TIA,
    Bill

  22. Gravatar ImageDominic Turner responded on 29 Jan 2013 at 6:12 am #

    I found I needed to add it to DotNetConfig40.xsd in
    C:\Program Files (x86)\Microsoft Visual Studio 11.0\Xml\Schemas

    This was using VS 2012 on a ASP.NET 4.0 site.

  23. Gravatar Imagesupriya salunkhe responded on 15 Feb 2013 at 1:43 am #

    i encountered with the following error when trying to run the script in cmd.

    “Failed to open file Xml\Schemas\DotNetConfig.xsd. Make sure that the script is run in the elevated command prompt.”
    im running cmd in admin mode.

    im using VS2008

  24. Gravatar ImageKamarey responded on 24 Feb 2013 at 5:17 am #

    @supriya salunkhe: Do the step described by the Brant Burnett (on 19 Oct 2012 at 11:40 am). After run the js command

  25. Gravatar ImageJohn O responded on 27 Mar 2013 at 4:25 am #

    I just updated this on VS2010 as the lack of intellisense had been p*ssing me off for ages. However the rewrite node doesn’t support xdt:transform so I’m back in the same position :(

  26. Gravatar Imagewhetteon responded on 03 Apr 2013 at 12:21 pm #

    Thanks for the comment Dominic Turner, I was about to give up on this solution.

  27. Gravatar ImageRob van Meeuwen responded on 11 Apr 2013 at 2:51 am #

    Hi,
    Great post, I used the 2.0 version with success on VS2012. Thanks to updated js script by Michal A. Valášek.
    I put it together for the VS2012 folks: http://blog.vanmeeuwen-online.nl/2013/04/visual-studio-2012-xml-intellisense-for.html

  28. Gravatar ImageRub responded on 14 Jul 2013 at 11:02 pm #

    I getting “Failed to open file Xml\Schemas\DotNetConfig.xsd. Make sure that the script is run in the elevated command prompt.”

    using VS2010 express.

    How to fix it?
    (Will I get message when you answer?)

  29. Gravatar ImageJames Taylor responded on 28 Mar 2014 at 12:40 am #

    im now getting this as my rewrite rule is in a transform file

    Warning 17 The ‘http://schemas.microsoft.com/XML-Document-Transform:Transform’ attribute is not declared.

Trackback URI | Comments RSS

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

XML Markup: If You want to add XML code to the comment please XML encode it first, otherwise the code will not show up.

Recently Published Articles