HttpUtility.UrlDecode # Hash Symbol

Hi All,

I use the following code which redirects a user to the URL which is stored within the variable 'strurlredi'..

Response.Redirect("http://" + HttpUtility.UrlDecode(strurlredi));

What I am finding is that if the URL passed within 'strurlredi' includes a # symbol on the end of it then my redirect doesn't function.

Does anyone have any ideas how I can overcome this?


Who is Participating?
Todd GerbertConnect With a Mentor IT ConsultantCommented:
Are you sure strurlredi is UrlEncoded in the first place?  A hash symbol should encode as %23 in a URL, and if the Decoded result is "" then that's a perfectly valid URL, but if the receiving server doesn't care for the hash then I'd say to put in strurlredi in the first place (although it would normally be ignored, I believe).
Tony McCreathConnect With a Mentor Technical SEO ConsultantCommented:
Could you explain what "doesn't function" means. Throws an exception? does nothing? Goes to the wrong place?

Is the hash for use  to move to an anchor or an accidental character within the URL?

What version of .Net are you using?

The use of UrlDecode does not seem right to me. What is the content of strurlredi
rito1Author Commented:
Hi Both,

I have sorted this by removing the # from the end of the URL. If I had more time on it then I would try figuring out why its giving me grief.


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.