Enabling URL Rewriting with ASP.NET using web.config

Enabling URL Rewriting with ASP.NET using web.config



I am brand new to ASP.NET, in fact I know pretty much nothing about it, but do not despair, I am not looking for a tutorial... A colleague of mine is wanting to run an ASP.NET application on our Webserver. Our Webserver is running Windows 2008 R2, with Plesk 11 and IIS 7.5.


ASP.NET


ASP.NET



So far I have had all sorts of problems trying to enable ASP.NET, but after a lot of fiddling around, I managed to get the application working (to a certain extent).


ASP.NET



However, in order to get the application to work, I had to remove the following lines from my web.config file:


web.config


<configSections>
<sectionGroup name="system.webServer">
<sectionGroup name="rewrite">
<section name="rewriteMaps" overrideModeDefault="Allow" />
<section name="rules" overrideModeDefault="Allow" />
</sectionGroup>
</sectionGroup>
</configSections>



This was because I was receiving the error:



Parser Error Message: Section or group name 'system.webServer' is
already defined. Updates to this may only occur at the configuration
level where it is defined.



My folder structure is like so:


website/
TestApplication/
web.config
index.php
web.config



I have created an Application for the folder 'TestApplication' (not that I really know what this means), but this has not made any difference.



I was under the impression that if you create an application, the web.config inside the directory will not inherit any of the parent configurations! This does not seem to be the case here as I am still receiving the error.


web.config



My question is, what am I meant to do with the above situation? How can I either prevent the application from inheriting the parent directories configurations, or alternatively, fix the current web.config file to work with ASP.NET?


web.config


ASP.NET



One thing to note, I have made changes in both IIS Manager, and Plesk as I was unable to find particular things in the Plesk Control Panel, for instance: creating an application for a directory within a website. I don't think this is the cause of the issue here, but nevertheless, worth mentioning.



This is my full web.config file (with all bar one of my rules removed as they have no impact on the file):


<?xml version="1.0" encoding="UTF-8"?>
<configuration>

<configSections>
<sectionGroup name="system.webServer">
<sectionGroup name="rewrite">
<section name="rewriteMaps" overrideModeDefault="Allow" />
<section name="rules" overrideModeDefault="Allow" />
</sectionGroup>
</sectionGroup>
</configSections>

<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
<rewrite>
<rules>
<clear />
<rule name="Browser Error Rewrite" stopProcessing="true">
<match url="^errors/browser$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="_errors/browser.php?error=browser" />
</rule>
</rules>
</rewrite>
<defaultDocument>
<files>
<clear />
<add value="index.php" />
</files>
</defaultDocument>
<httpErrors>
<clear />
<error statusCode="400" prefixLanguageFilePath="" path="/_errors/error.php?id=400" responseMode="ExecuteURL" />
<error statusCode="502" prefixLanguageFilePath="" path="/_errors/error.php?id=502" responseMode="ExecuteURL" />
<error statusCode="407" prefixLanguageFilePath="" path="/_errors/error.php?id=407" responseMode="ExecuteURL" />
<error statusCode="414" prefixLanguageFilePath="" path="/_errors/error.php?id=414" responseMode="ExecuteURL" />
<error statusCode="415" prefixLanguageFilePath="" path="/_errors/error.php?id=415" responseMode="ExecuteURL" />
<error statusCode="501" prefixLanguageFilePath="" path="/_errors/error.php?id=501" responseMode="ExecuteURL" />
<error statusCode="500" prefixLanguageFilePath="" path="/_errors/error.php?id=500" responseMode="ExecuteURL" />
<error statusCode="401" prefixLanguageFilePath="" path="/_errors/error.php?id=401" responseMode="ExecuteURL" />
<error statusCode="403" prefixLanguageFilePath="" path="/_errors/error.php?id=403" responseMode="ExecuteURL" />
<error statusCode="404" prefixLanguageFilePath="" path="/_errors/error.php?id=404" responseMode="ExecuteURL" />
<error statusCode="405" prefixLanguageFilePath="" path="/_errors/error.php?id=405" responseMode="ExecuteURL" />
<error statusCode="412" prefixLanguageFilePath="" path="/_errors/error.php?id=412" responseMode="ExecuteURL" />
<error statusCode="406" prefixLanguageFilePath="" path="/_errors/error.php?id=406" responseMode="ExecuteURL" />
</httpErrors>
<handlers>
<clear />
<add name="PageHandlerFactory-Integrated" path="*.aspx" verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory" preCondition="integratedMode" />
<add name="php-5.3.10" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:Program Files (x86)ParallelsPleskAdditionalPleskPHP53php-cgi.exe" resourceType="Either" requireAccess="Script" />
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" />
</handlers>
</system.webServer>
</configuration>






did you try IIS url rewrite module? URL rewrite module

– ravisilva
Jan 24 '13 at 13:00






@RaviSilva That is what created these configSections blocks in the first place, but thanks anyway :-). I have now sorted, will post an answer later

– Ben Carey
Jan 24 '13 at 13:09


configSections






@Ben Carey - how did you solve it?

– Justin
Jul 28 '13 at 19:54






IIS URL Rewrite module won't touch your web.config and generate the configSections. If it does, that should be considered a bug. You can remove it from your web.config file safely.

– Lex Li
Feb 22 '15 at 5:12



configSections




2 Answers
2



It seems that you have twice in your web.config (that's what the "Parser Error Message: Section or group name 'system.webServer' is already defined" error implies).



Search for in your application's web.config and cut the code in it and paste it to another one(make sure that code doesn't repeating) remove that one you have cut the code from






Yes this is pretty clear from the error message, however, I cannot remove one of them because I need it in order for the URL rewriting to work!

– Ben Carey
Jan 24 '13 at 11:30






can u post your web.config code obviously after removing sensitive information?

– Syed Salman Raza Zaidi
Jan 24 '13 at 11:34






Sure thing, give me two mins :-)

– Ben Carey
Jan 24 '13 at 11:39






check my updated answer as well

– Syed Salman Raza Zaidi
Jan 24 '13 at 11:40






The config file you are referring to is the master config file, not one that should be edited. Not to mention the fact that it will apply that configuration to all of my websites! I have posted my web.config file

– Ben Carey
Jan 24 '13 at 11:43




If you are using a newer version of IIS or using Windows Azure, you don't need the <ConfigSection>. It is built-in in the new IIS. Simply go ahead and use <rewrite> tag directly under <system.webServer> in your web.config.


<ConfigSection>


<rewrite>


<system.webServer>






Not true. Only if you use Azure Web Sites, the module is installed by default. Windows Server or desktop not yet ships with IIS URL Rewrite.

– Lex Li
Feb 22 '15 at 5:10



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế