31

i'm using ASP.net with .NET 3.5 on IIS7 (Vista) with the URL Rewrite Module from Microsoft.

This means, that i have a

<system.webServer>
    <rewrite>...</rewrite>
    ...
</system.webServer>

section within the web.config, but i get a warning, that within the system.webServer the element "rewrite" is not allowed.

How can i configure my system to allow (and maybe even have Intellisense) on the rewrite-part of the web.config?

Thank you Christoph

Christoph
  • 915
  • 1
  • 12
  • 23

3 Answers3

25

I was able to get this working in Visual Studio 2010.

Start with Ruslan's post here and download the 2.0 IntelliSense file. Then, just follow the directions he posted previously here. All I ended up doing was running the following command as Ruslan instructs:

C:\download_directory\rewrite2_intellisense>cscript UpdateSchemaCache.js

As Christoph points out in his comment, make sure you replace VS90COMNTOOLS with VS100COMNTOOLS in UpdateSchemaCache.js before running the above command if you are using Visual Studio 2010.

I did not need to restart Visual Studio. I added the <rewrite> section only to the applicable Web.config transformation files, as having it in the main Web.config breaks local debugging.

Jon
  • 4,925
  • 3
  • 28
  • 38
  • 4
    Hi Jon, thanks for the link. Works good in vs2010 but be aware if you use vs2010 you need to change in the UpdateSchemaCache.js the "VS90COMNTOOLS" to "VS100COMNTOOLS" (hint for other users :-) ) – Christoph Aug 16 '10 at 14:35
  • Hi Jonathan. About that web.config transform - what does yours look like? The only way I can see to do it is to add a second system.webServer section containing the and . I'd rather not add a second section. Do you have a more elegant way? – Eric Jan 07 '11 at 17:04
  • @Jon FreeLand - I get this error(even though I am running it the cmd prompt as an admin) Failed to open file Xml\Schemas\DotNetConfig.xsd. Make sure that the script is run in the elevated command prompt. – chobo2 Feb 21 '12 at 17:52
  • So do I. Is there a problem with the Express Version of VS 2010? – Tillito Feb 28 '12 at 13:19
  • Sorry guys, I do not know if this will work with Express. I am using Ultimate. – Jon Feb 28 '12 at 15:01
  • That guys article is frustrating to follow. It gives you the rewrite code, but doesn't tell you where exactly to place it in the web.config. – The Muffin Man Mar 09 '13 at 07:57
  • Ruslan's website is gone. Is there any other way to do this? –  Jul 20 '15 at 10:33
3

I believe you need to define the module in your web.config like this:

<system.webServer>
    <modules>
        <add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />
    </modules>
</system.webServer>

Update: Intellisense can be setup here:

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

Update: Verify that the sectionGroup is identified in %systemroot%\system32\inetsrv\config\applicationHost.config:

<sectionGroup name="rewrite">
    <section name="rules" overrideModeDefault="Allow" />
    <section name="globalRules" overrideModeDefault="Deny" allowDefinition="AppHostOnly" />
    <section name="rewriteMaps" overrideModeDefault="Allow" />
</sectionGroup>
mellamokb
  • 56,094
  • 12
  • 110
  • 136
3

I believe you need to have the URL Rewrite Module "installed" within the web.config file on your system.

You either need to install the module on your application via the IIS 7.0 interface or have your hosting firm do it for you.

Randy Burgess
  • 4,835
  • 6
  • 41
  • 59
  • nope, i installed the Rewrite Module several times on several Mashines (Vista and Win7) via the Web Platform Installer 2.0 and the native Installer from IIS.net – Christoph May 22 '09 at 14:58