Solved

ASP.Net Querystring with special characters

Posted on 2008-10-23
3
193 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
  • 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 500 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Remove greater than sign 3 68
Error on Add method 1 50
Example works but why do I need to click twice on button 4 36
Please explain the parts of these 2 LINQ expressions 3 26
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 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