ASP.Net MVC Style Extensionless URLs

Posted By BORNXenon Mon 4 Aug 2014
Add to Favorites0
Author Message
BORNXenon
 Posted Mon 4 Aug 2014
Supreme Being

Supreme Being - (33,943 reputation)Supreme Being - (33,943 reputation)Supreme Being - (33,943 reputation)Supreme Being - (33,943 reputation)Supreme Being - (33,943 reputation)Supreme Being - (33,943 reputation)Supreme Being - (33,943 reputation)Supreme Being - (33,943 reputation)Supreme Being - (33,943 reputation)

Group: Forum Members
Last Active: Mon 23 Apr 2018
Posts: 59, Visits: 291
I'm sure I've seen a post on here at some point regarding ASP.Net MVC style extensionless URLs, however, I can't find it!

Well I quite like the extensionless URL feature provided by the MVC routing engine, happily, the same feature can be employed in Web Forms quite easily with a rewrite rule added to the web.config file.

All that you need to do is find the
<system.webserver>
tag within your web.config file and add the following lines:
<rewrite>
<rules>
<rule name="extensionless" stopProcessing="true">
<match url="(.*)\.aspx$" />
<action type="Redirect" url="{R:1}" redirectType="Permanent" />
</rule>
<rule name="removeextension" enabled="true">
<match url=".*" negate="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="{R:0}.aspx" />
</rule>
</rules>
</rewrite>

Enjoy!
Mon 4 Aug 2014 by BORNXenon

Threaded View

Expand / Collapse
Threaded View
Forum Post ASP.Net MVC Style Extensionless URLs By BORNXenon ( Mon 4 Aug 2014 )

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Back To Top