Request.QueryString and Server.URLDecode()

  • Thread starter Thread starter John Grandy
  • Start date Start date
J

John Grandy

Does Server.URLDecode() need to be applied to Request.QueryString(<key
name>) ?
 
Does Server.URLDecode() need to be applied to Request.QueryString(<key
name>) ?

Yes - if the string is encoded. Request.Querystring returns the raw
(undecoded) text.
 
Yes, as I discovered this is also important when using Base64-encoded
strings in the QueryString. Here's what I use to combat frustration:

string sOKForBase64Decrypt =
Server.UrlDecode(Request.QueryString["argument"].ToString()).Replace("
","+")

-- Sean M
 
Hmmm ...

My tests don't show any need to apply Server.URLDecode() to
Request.QueryString()

I tested a return URL of

http://localhost/Results.aspx?search=here+are+some+spaces

Debug-mode stepping through the server-side code ,
Request.QueryString("search") contains the value "here are some spaces" (no
plus signs are included)







Sean M said:
Yes, as I discovered this is also important when using Base64-encoded
strings in the QueryString. Here's what I use to combat frustration:

string sOKForBase64Decrypt =
Server.UrlDecode(Request.QueryString["argument"].ToString()).Replace("
","+")

-- Sean M

John Grandy said:
Does Server.URLDecode() need to be applied to Request.QueryString(<key
name>) ?
 
Lucas said:
Yes - if the string is encoded. Request.Querystring returns the raw
(undecoded) text.

Um... no. Items retrieved from the QueryString collection have already
been decoded (anything else would be disastrous).

Cheers,
 
Um... no. Items retrieved from the QueryString collection have already
been decoded (anything else would be disastrous).

Oops you're right : )

Always thought you needed to run it through Server.URLDecode.
 
Hmmm ...

My tests don't show any need to apply Server.URLDecode() to
Request.QueryString()

I think it may of been out of habit from ASP days???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top