简体   繁体   English

如何从vb.net的网址中删除%20%20

[英]How to remove %20%20 from url in vb.net

I am getting problem in url.%20%20 is adding in url.I have tried HttpUtility.UrlEncode Method. 我在url中遇到问题。%20%20正在url中添加。我尝试了HttpUtility.UrlEncode方法。

But still it shows %20%20 in url. 但它仍显示%20%20的网址。

Here is code that i am using: 这是我正在使用的代码:

redirectUrl += "&return=" & Server.UrlEncode(ConfigurationManager.AppSettings("SuccessURL") & "?item_name=" + Server.UrlEncode(ItemDescription.ToString()) + "&amount=" + Server.UrlEncode(Amount.ToString()) + "&quantity=" + Server.UrlEncode(qty.ToString()))

Here is return url in browser: 这是浏览器中的返回网址:

http://localhost:53725/Project/SuccessPayment.aspx%20%20?item_name=%2b%27ULTRA%2bANTI-STATIC%2bWRIST%2bSTRAP%27&amount=9%2e99&quantity=1

If i will able to remove %20%20 before querystring variable(?).Then url will work for me. 如果我能够在querystring variable(?)之前删除%20%20。那么url对我有用。

Please suggest me how i can solve this. 请建议我如何解决这个问题。

%20 is a space character. %20是空格字符。 So you need to trim it away: 因此,您需要将其修剪掉:

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()))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM