Click here to Skip to main content
14,932,183 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,

I have a strange issue.

Url pattern = "~/app/4/Search/"SearchTerm""


the "SearchTerm" is a string entered in search text box as is with single or double quotes, and up on clicking the search button, the page gets redirected to above url.

every thing is working fine in non IE browsers,

but in IE, up on clicking search button, page not found is shown...

please suggest how to fix this in IE

thanks in advance
Posted
Updated 27-May-21 4:34am
Comments
Maciej Los 9-Jul-14 10:19am
   
Use search term without single/double quotes ;)
CHill60 9-Jul-14 10:21am
   
escape the double-quotes e.g. Url pattern = "~/app/4/Search/\"SearchTerm\"";

1 solution

Try "URLEncode"ing the quotes:
Double quote (") becomes "
Single quote (') becomes '

If the url is being generated dynamically, you can use Server.UrlEncode(url) to automatically encode the whole url.

If you only need to encode part of the url you can do something like this:
C#
string url = string.Format("~/app/4/Search/{0}", Server.UrlEncode(searchTerm));

I highly recommend that urls (in whole or part) entered in a text box be encoded prior to use.
   
v4
Comments
ZurdoDev 10-Jul-14 15:05pm
   
+5
Maciej Los 10-Jul-14 16:05pm
   
+5!
Maciej Los 10-Jul-14 16:08pm
   
BTW: Sygitowicz... - sounds like a polish surname. Have you polish roots?
Cheers,
Maciej

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900