?
Solved

query string issue with pound sign

Posted on 2014-07-24
3
Medium Priority
?
500 Views
Last Modified: 2014-07-25
Im having an issue with users entering pound signs into values that are going into query string and messing up the url.

customer
textbox value:  #beta

query string
Then when they press a button to redirect to a new page they get a 404 error.

404
Here is the code.

  Response.Redirect(Rainbow.HttpUrlBuilder.BuildUrlByPath("Rating/Edit Contract/Change Contract","&spot=y" + "&cust=" + txtCustomer.Text + "&div=" + txtDivision.Text)); 

Open in new window

The offending code there is the &cust variable.  If a user enters a # in front of the value it causes a 404 error.

On the page im redirecting to im using the variable as such.

  if (Request.QueryString["cust"] != null)
                {
                    txtCustomer.Text = Request.QueryString["cust"];
                }

Open in new window


So im wondering if there is a way for me to handle special chars like * or # in the query string.

Thanks
0
Comment
Question by:hougie40
[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 26

Expert Comment

by:Shaun Kline
ID: 40217863
You should use the HttpServerUtility.UrlEncode to encode your values for inclusion in your URL.
See reference: http://msdn.microsoft.com/en-us/library/zttxte6w(v=vs.110).aspx.
0
 

Author Comment

by:hougie40
ID: 40218197
The url.encode works fine with those urls that have # in them but not with those that have * in them.

I should have mentioned earlier that customer code can be preceded with # or *.  So in the case of the * i am not sure how to handle those.
0
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 2000 total points
ID: 40219366
The asterisk is a special reserved character and is not encoded with that utility. You will need to encode and decode it manually using a string replace method. The correct encoding value is %2A.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

800 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