找不到HTTP错误404.11:双重转义序列 [英] HTTP Error 404.11 Not Found: double escape sequence

查看:60
本文介绍了找不到HTTP错误404.11:双重转义序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 OpenSearch 搜索产品的C#MVC 3项目.如果搜索词是一个单词,那么搜索就很好,但是如果输入 canned food 之类的字词,则会出现 HTTP错误404.11 .我知道解决此问题的一种简单方法是将 allowDoubleEscaping 设置为 webconfig 中的 true .但是我的朋友建议我使用转义url ,用%20 替换 space (如果我错了,请更正我,因为我是新手.这个)

I have a C# MVC 3 project that uses OpenSearch to search for product. Search is fine if the search word is one word but if I type something like canned food then I get HTTP Error 404.11. I know that one easy way to fix this is set the allowDoubleEscaping equals to true in webconfig. But my friend suggested me to use escaping url which would replace the space with %20 (correct me if I am wrong because I am new to this)

我已经看到了很多使用 UrlPathEncode 的示例,但是我不确定将这些代码添加到我的项目中的哪个位置.

I have seen a lot of examples that says to use UrlPathEncode but I am not sure where to add this code in my project.

基本上我只是问我该怎么做:

Basically I am just asking how can I make this:

localhost:94830/Home/Search/canned food

进入此

localhost:94830/Home/Search/canned%20food 

或用其他字符替换空格

localhost:94830/Home/Search/canned-food

推荐答案

您可以使用 System.Uri.EscapeUriString 如下:

You can use System.Uri.EscapeUriString as follows:

Uri.EscapeUriString("double  space") //double%20%20space

,并且在客户端配置文件"中也可以使用,因此它比使用 System.Web API更具可移植性.

and as it's also available in "client profile", it's more portable than using System.Web APIs.

这篇关于找不到HTTP错误404.11:双重转义序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆