Solved

ASP.Net Querystring with special characters

Posted on 2008-10-23
3
191 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
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.
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 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

17 Experts available now in Live!

Get 1:1 Help Now