Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在ASP.NET中正确编码包含符号和的url?_C#_Asp.net_Iis_Urlencode_Url Encoding - Fatal编程技术网

C# 如何在ASP.NET中正确编码包含符号和的url?

C# 如何在ASP.NET中正确编码包含符号和的url?,c#,asp.net,iis,urlencode,url-encoding,C#,Asp.net,Iis,Urlencode,Url Encoding,如何正确编码以下url http://mysite/myapp/content/Documents/Opening Leave Case for Supervisors-WC&TW.pdf 当我在url编码文件名后查看url时,出现以下错误: “请求筛选模块配置为拒绝包含双转义序列的请求。” 我确信问题在于文件名中的符号,但不确定如何正确处理它 以下是迄今为止我所拥有的(不起作用的): 您可以尝试HttpUtility.UrlPathEncode,它将空间转换为“%20”而不是“+”。

如何正确编码以下url

http://mysite/myapp/content/Documents/Opening Leave Case for Supervisors-WC&TW.pdf
当我在url编码文件名后查看url时,出现以下错误:

“请求筛选模块配置为拒绝包含双转义序列的请求。”

我确信问题在于文件名中的符号,但不确定如何正确处理它

以下是迄今为止我所拥有的(不起作用的):


您可以尝试HttpUtility.UrlPathEncode,它将空间转换为“%20”而不是“+”。除此之外,我认为你所做的没有错


此外,您还需要发布该错误发生的上下文,因为该错误显然不会在转换时发生。

可能与您从何处获得该错误的代码重复?(我确信这不是直接来自URL编码。)Jashaszun-我更新了我的问题,提供了关于如何生成错误的更多细节。
string.Concat( "~/Content/Documents/", HttpUtility.UrlEncode( ContentLocation ) );