开发者

Http POST request url contains '['

I am working with SharePoint using http post request. My url contains '[' so I am getting some exception.

Does anybody knows how to send a Post or Get request if the url contains 开发者_高级运维'[' or ']' character?


Encode the brackets in the url so that [ becomes %5B and ] becomes %5D.
HTML URL Encoding Reference

If you are generating the URL from (.NET) code, use HttpServerUtility.UrlEncode().

string encodedUrl = "http://example.com/awesome.aspx?title="
                  + HttpServerUtility.UrlEncode("Super & Delicious Program [v1]");

// "http://example.com/awesome.aspx?title=Super+%26+Delicious+Program+%5Bv1%5D"

The (roughly) equivalent method in JavaScript would be escape().


Encode the square brackets

[ == %5B
] == %5D


If you're using PHP, try out htmlspecialchars. To decode use htmlspecialchars_decode.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜