1,105,288 Community Members

URL Rewrite 2.0 - replacing spaces with hyphens in URLs

Member Avatar
TheAlex
Junior Poster in Training
67 posts since Feb 2005
Reputation Points: 1 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

Is it best (or even possible) to replace spaces using URL Rewrite or using ASP/ASP.net before the URL is sent? If it's the former, can it be done with a wizard within IIS? Also, I will need to replace capital letters and accented characters with an equivalent e.g. é with e, is this best done with URL Rewrite?

I've tried some of the tutorials on the official IIS website and have got through a simple rewrite wizard, but replacing characters seems more complicated, and I'm sure some of the tutorials have errors in them...

Thanks for any help. :)

Member Avatar
Fortinbra
Posting Whiz in Training
236 posts since Jan 2011
Reputation Points: 37 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 4 [?]
 
0
 

I can't remember the specific namespace, but .NET has a built in URLEncode, and URLDecode functions that take a string and make it compliant with standard URLs

Member Avatar
TheAlex
Junior Poster in Training
67 posts since Feb 2005
Reputation Points: 1 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks, though I don't think that's what I need as it changes spaces to pluses and non-standard characters to a % and hexadecimal value.

Member Avatar
Fortinbra
Posting Whiz in Training
236 posts since Jan 2011
Reputation Points: 37 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 4 [?]
 
0
 

Alright, I'm guessing you aren't going to be using the string in an URL then.

Member Avatar
TheAlex
Junior Poster in Training
67 posts since Feb 2005
Reputation Points: 1 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

The URL I want will be something like this: www.webaddress.com/150211/title-of-news-article instead of www.webaddress.com/article.asp?date=150211&title=title-of-news-article

Member Avatar
Fortinbra
Posting Whiz in Training
236 posts since Jan 2011
Reputation Points: 37 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 4 [?]
 
0
 

you might try this http://www.4guysfromrolla.com/articles/012710-1.aspx this is specific to .NET 4, but the feature exists in the older versions

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: