Click here to Skip to main content
15,793,609 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 the above URL.

Everything works 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!
Updated 23-Feb-22 4:32am
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:
string url = string.Format("~/app/4/Search/{0}", Server.UrlEncode(searchTerm));

I highly recommend that urls (in whole or part) entered in a textbox be encoded prior to use.
Share this answer
ZurdoDev 10-Jul-14 15:05pm    
Maciej Los 10-Jul-14 16:05pm    
Maciej Los 10-Jul-14 16:08pm    
BTW: Sygitowicz... - sounds like a polish surname. Have you polish roots?

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

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