URL Encoding - Illegal Character Replacement
- by ThePower
Hi,
I am doing some url redirections in a project that I am currently working on. I am new to web development and was wondering what the best practise was to remove any illegal path characters, such as ' ? etc.
I'm hoping I don't have to resort to manually replacing each character with their encoded urls.
I have tried UrlEncode and HTMLEncode, but UrlEncode doesn't cater for the ? and HTMLEncode doesn't cater for '
E.G. If I was to use the following:
Dim name As String = "Dave's gone, why?"
Dim url As String = String.Format("~/books/{0}/{1}/default.aspx", bookID, name)
Response.Redirect(url)
I've tried wrapping url like this:
Dim encodedUrl As String = Server.UrlEncode(url)
And
Dim encodedUrl As String = Server.HTMLEncode(url)
Thanks in advance.
P.S. Happy Christmas