user1909128
user1909128

Reputation: 11

How to remove percent sign from url

By mistake I have made few asp pages having % sign.For example 100%cotton.aspx. Now when i am trying to open it on url.it says: Bad Request - Invalid URL HTTP Error 400. The request URL is invalid. How to resolve this issue?

Upvotes: 1

Views: 2163

Answers (1)

Alexei Levenkov
Alexei Levenkov

Reputation: 100537

It is unclear what the problem is but properly encoded % in the path should not cause problems. % is ok in "path" portion of Url, but need to be properly encoded as %25.

The best way to deal with all encoding is to use Uri or UriBuilder classes to construct urls:

 var url = new Uri("http://foo/bar%test").AbsoluteUri

The other option (as suggested by ashutosh raina) is to simply not use % in file names. Note that it does not mean you should not be constructing urls properly.

Upvotes: 1

Related Questions