ASP.NET URL Redirection

How to rewrite url in ASP.NET?

I would like for users to be able to go http://www.website.com/users/smith instead of http://www.website.com/?user=smith

+28
url url-rewriting url-routing rewrite
Aug 05 '08 at 13:14
source share
4 answers

Try restarting the URL of the managed fuser and reverse proxy:

http://urlrewriter.codeplex.com

Rule for rewriting:

# clean up old rules and forward to new URL RewriteRule ^/?user=(.*) /users/$1 [NC,R=301] # rewrite the rule internally RewriteRule ^/users/(.*) /?user=$1 [NC,L] 
+23
Aug 05 '08 at 13:18
source share
— -
Scott Guthrie talks about how to do this initially in .Net quite widely here .

I used the httpmodule approach and it works well. This is basically what ManagedFusion does for you.

+20
Aug 05 '08 at 13:28
source share

Microsoft now ships the official URL rewrite module for IIS: http://www.iis.net/download/urlrewrite

It supports most types of rewriting, including setting server variables and wildcards.

It will also exist in all Azure web instances out of the box.

+5
Oct 01 '10 at 11:52
source share

I used httpmodule to rewrite url from www.urlrewriting.net with great success (although I find a much earlier, simpler version)

If you have very few actual rewrite rules, then url mappings built into .NET 2.0 are probably an easier option, there are a few emails from them on the Internet, 4guysfromrolla alone seems pretty comprehensive, but since you can see that they are not support regular expression comparisons, as such, turn out to be useless in a dynamic environment (assuming that the "blacksmith" in your example is not a special case, then it would be useless)

+4
Aug 11 '08 at 13:44
source share



All Articles