【发布时间】:2011-05-31 17:45:35
【问题描述】:
我需要对一些句点进行 URL 编码,因为我必须传递一些文档路径,就像这样
http://example.com/test.aspx?document=test.docx
所以 test.docx 导致我出现非法字符错误。所以我需要把它改成
. --> %2E
我尝试使用 Server.UrlEncode
string b = Server.UrlEncode("http://example.com/test.aspx?document=test.docx");
但我明白了
"http%3a%2f%2fexample.com%2ftest.aspx%3fdocument%3dtest.docx"
那么我是否必须像字符串替换一样使用并手动执行并用该代码替换所有句点?
【问题讨论】:
-
你确定是
.吗?对我来说,这看起来像是一个完全有效的查询字符串。
标签: c# urlencode url-encoding