shivani
shivani

Reputation: 23

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.

But still it shows %20%20 in url.

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.

Please suggest me how i can solve this.

Upvotes: 1

Views: 1236

Answers (1)

SynerCoder
SynerCoder

Reputation: 12766

%20 is a space character. 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()))

Upvotes: 1

Related Questions