url查询字符串中的双引号重定向到IE中找不到的页面 [英] double quotes in url query string redirects to page not found in IE
问题描述
大家好,
我有一个奇怪的问题。
Url pattern =〜/ app / 4 /搜索/ SearchTerm
< u> SearchTerm 是在搜索文本框中输入的字符串,其中带有单引号或双引号,单击搜索按钮后,页面获取重定向到上面的网址。
在非IE浏览器中,每件东西都能正常工作,
但在IE中,点击搜索按钮,页面未找到...
请在IE中建议如何解决这个问题
提前谢谢
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
推荐答案
尝试URLEncode引号:
双引号()成为& quot;
单引号(')变为&#39;
如果网址是动态生成的,您可以自动使用Server.UrlEncode(url)编码整个网址。
如果您只需编码部分网址,您可以执行以下操作:
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 text box be encoded prior to use.
这篇关于url查询字符串中的双引号重定向到IE中找不到的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!