Reputation: 56
I am new to URLRewriting and trying to remove the .aspx extension using the following script in my web.config
<configuration>
<configSections>
<section name="rewriteModule" type="RewriteModule.RewriteModuleSectionHandler, RewriteModule"/>
</configSections>
<connectionStrings>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to clean URL" stopProcessing="true">
<match url="^([a-z0-9/]+).aspx$" ignoreCase="true"/>
<action type="Redirect" url="{R:1}"/>
</rule>
</rules>
</rewrite>
</system.webServer>
However, I have no success with this. Moreover, the following code block is giving me an error.
<httpHandlers>
<add verb="*" path="*.aspx"
type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</httpHandlers>
> Could not load file or assembly 'URLRewriter' or one of its
> dependencies. The system cannot find the file specified.
Do I need to add the rewrite engine to my web application?
I have gone through this link but I could not get it.
Can any one suggest to me a step by step process or sample script please?
Upvotes: 0
Views: 2775
Reputation: 5126
Use the following rule, works like a charm everytime!
<rule name="san aspx">
<!--Removes the .aspx extension for all pages.-->
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.aspx" />
</rule>
Upvotes: 1
Reputation: 1399
(As alternatives to writing your own)
IIS 7 URL rewrite module :
http://www.microsoft.com/en-gb/download/details.aspx?id=7435
IIS 5/6 :
Upvotes: 0
Reputation: 7341
Seems like you have not added the dll Reference in the Web project for the class URLRewriter. Add this reference to fix this issue.
Upvotes: 0
Reputation: 317
Here is some nice rewritting engine with how-to's :)
http://www.codeproject.com/Articles/2538/URL-Rewriting-with-ASP-NET
Upvotes: 0