SEO friendly url gives a "A potentially dangerous Request.Path" on IIS
I'm creating a SEO friendly URL which has some product names, which might have not-so-url friendly characters, eg:
www.foo.com/some-friend/product-name-bla-%numbers-maybe/1234567
I'm only interested in the last id number, however currently IIS redirects to a f开发者_JS百科ault page on some of of my URLs.
I do not wish to disable the Request.Path check.
My question is - How do I sanitize the URLs so they will not bother IIS (preferably in C#) ?
ASP.NET has HttpUtility which lets you escape illegal characters in url or html string.
HttpUtility.UrlEncode(yourString);
Even though you are only going to need the ID at the end of the URL to get data from database, it is a good idea to also check if the SEO friendly part of the url is identical to original url.
If for whatever reason it has changed you should do a 301 permanent redirect to the original in order to avoid creating duplicate content.
Also setting up a canonical meta tag would help you prevent that issue.
精彩评论