假设以下网址:
"http://server/application1/TestFile.aspx?Library=Testing&Filename=Documents & Functions + Properties.docx&Save=true"
我使用 HttpUtility.UrlEncode() 对 Filename 参数的值进行编码,并创建以下 Url:
"http://server/application1/TestFile.aspx?Library=Testing&Filename=Documents%20%26%20Functions%20%2B%20Properties.docx&Save=true"
我将以下请求(编码版本)从客户端发送到 C# Web 应用程序。在服务器上,当我处理请求时,我遇到了问题。HttpRequest 变量包含部分解码的查询字符串。也就是说,当我尝试使用或快速查看 HttpRequest 的以下属性时,它们具有以下值。
Property = Value
================
HttpRequest.QueryString = "{Library=Testing&Filename=Documents+&+Functions+++Properties.docx&Save=true}"
HttpRequest.Url = "{http://server/application1/TestFile.aspx?Library=Testing&Filename=Documents & Functions + Properties.docx&Save=true}"
HttpRequest.Url.AbsoluteUri = "http://server/application1/TestFile.aspx?Library=Testing&Filename=Documents%20&%20Functions%20+%20Properties.docx&Save=true"
我还检查了以下属性,但它们都解码了 & 值。然而,所有其他值都保持正确编码(例如空格是 %20)。
HttpRequest.Url.OriginalString
HttpRequest.Url.Query
HttpRequest.Url.PathAndQuery
HttpRequest.RawUrl
我无法正确读取参数 Filename 的值。我错过了什么吗?