Solved

ASP.Net Querystring with special characters

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

688 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