?
Solved

ASP.Net Querystring with special characters

Posted on 2008-10-23
3
Medium Priority
?
197 Views
Last Modified: 2012-06-27
I am trying to send a query string like this

?tmp=black&amp:white

when I try to read it back I just get black

I am using server.urlencode  but does not work also tried server.htmlencode

Any Ideas?
0
Comment
Question by:JonMny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Expert Comment

by:Bane83
ID: 22787900
You have to use Server.UrlEncode on "black&white" before you add it to the querystring.  This will work.
0
 
LVL 9

Author Comment

by:JonMny
ID: 22788083
This is what the querystring looks like after the url encode, does not work
 
http://localhost:8080/tst/siteizard.aspx%3fregionid%3d8%26clientname%3dBlack+%26amp%3b+White%26newhrcloan%3dtrue
0
 
LVL 10

Accepted Solution

by:
Bane83 earned 2000 total points
ID: 22788144
You're doing a UrlEncode on the string including the "?" and "="s.  You don't want to UrlEncode the entire string, just the values

Example of how to do this properly:

StringBuilder qs = new StringBuilder();
qs.Append("?regionid=");
qs.Append(Server.UrlEncode(regionid));
qs.Append("&clientname=");
qs.Append(Server.UrlEncode(clientname));
qs.Append("&newhrcloan=");
qs.Append(Server.UrlEncode(newhrcloan));

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question