Solved

ASP.Net Querystring with special characters

Posted on 2008-10-23
3
192 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending E-mail ASP.Net 3 56
Need a complete list of ASP.NET page load events 3 28
Data is not showing from images 15 38
Gridview alignment 1 10
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now