Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Query String parameter value truncate after #

Problem – The query string parameter value is getting truncated if I have # in the parameter string value.

I have a table where I am binding the anchor tag <a/> prop href value like below;

<a class="btn btn-primary" href="/FileDetails/DownloadBlob?dirName=@data.FolderName&blobName=@data.FileName">

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

after binding on browser:

<a class="btn btn-primary" href="/FileDetails/DownloadBlob?dirName=RSHSYNCADE&amp;blobName=J231132 anyfoostringnjectable barfoorBstringch #212422627, string Batch #145876V.pdf">

In the above anchor tag for href prop value I am setting a Controller/Action along with the query string parameters dirName and blobName.

But when the control comes to the specified action method of the controller it truncates the second param value from # means I can only see a value upto J231132 anyfoostringnjectable barfoorBstringch.

While trying to find a fix on internet, I am unable to find a proper solution which fit to my scenario till now.

Can anyone please help me to understand what causing this issue and what would be the fix for these kind of issues?

>Solution :

You need to encode the url that you put in the anchor href. If that values comes from the server, use HttpServerUtility.UrlEncode when you set the href tag. Otherwise you can use encodeURIComponent function in javscript or replace the "#" with "%23"

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading