我在url中遇到问题。%20%20正在url中添加。我尝试了HttpUtility.UrlEncode方法。
但它仍显示%20%20的网址。
这是我正在使用的代码:
redirectUrl += "&return=" & Server.UrlEncode(ConfigurationManager.AppSettings("SuccessURL") & "?item_name=" + Server.UrlEncode(ItemDescription.ToString()) + "&amount=" + Server.UrlEncode(Amount.ToString()) + "&quantity=" + Server.UrlEncode(qty.ToString()))
这是浏览器中的返回网址:
http://localhost:53725/Project/SuccessPayment.aspx%20%20?item_name=%2b%27ULTRA%2bANTI-STATIC%2bWRIST%2bSTRAP%27&amount=9%2e99&quantity=1
如果我能够在querystring variable(?)之前删除%20%20。那么url将对我有用。
请建议我如何解决这个问题。
%20
是空格字符。因此,您需要将其修剪掉:
redirectUrl = Server.UrlDecode(redirectUrl).Trim() + "&return=" & Server.UrlEncode(ConfigurationManager.AppSettings("SuccessURL") & "?item_name=" + Server.UrlEncode(ItemDescription.ToString()) + "&amount=" + Server.UrlEncode(Amount.ToString()) + "&quantity=" + Server.UrlEncode(qty.ToString()))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句