Hyperlink encoding space as %2520 instead of %20 not sure why? (Need a work around)

I have an asp.net web application with a grid.  One column has a bulleted list with displaytype as Hyperlink. It is databound. I return some folder paths in this list. If the path is a share on a server all works find as example 1.

In example 1 the spaces are replace by %20.

But for some reason in Example 2 when the actual drive letter is used the spaces are replaced by %2520 which then does not work.

1.file://server1/scanned/ASB/DE/AGOPSOWICZ,%20DANIEL/AGOPSOWICZ,%20DANIEL%202018%2011%2014


2.file:///Q:/ASB/DE/AGOPSOWICZ,%2520DANIEL/AGOPSOWICZ,%2520DANIEL%25202019%252002%252021


What causes this %2520 to happen? In example 1 with %20 the link works.

It looks like an encoding issue in the Bulleted list Hyperlink. It is adding the %2520 on the Example 2.

Thanks,

Roger
LVL 8
Rog DSQL Developer / Web Development / Business AnalysisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPRetiredCommented:
The way you get %2520 is when your url already has a %20 in it, and gets urlencoded again, which transforms the %20 to %2520.

Are you (or any framework you might be using) double encoding characters?

Edit: Expanding a bit on this, especially for LOCAL links. Assuming you want to link to the resource C:\my path\my file.html:

if you provide a local file path only, the browser is expected to encode and protect all characters given (in the above, you should give it with spaces as shown, since % is a valid filename character and as such it will be encoded) when converting to a proper URL (see next point).
if you provide a URL with the file:// protocol, you are basically stating that you have taken all precautions and encoded what needs encoding, the rest should be treated as special characters. In the above example, you should thus provide file:///c:/my%20path/my%20file.html. Aside from fixing slashes, clients should not encode characters here.
https://stackoverflow.com/questions/16084935/a-html-space-is-showing-as-2520-instead-of-20

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rog DSQL Developer / Web Development / Business AnalysisAuthor Commented:
Thanks for your insight to the File://  I will be trying this and testing this out.

Roger
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.