Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control colon (:) URL Query String?

Tags:

c#

asp.net

I need to pass the Query String of ID in which colon (:) is included i.e. ABC_PD:123456. When I am using this ID in query String session and when its redirect to another page in URL it give 404 no error found error on webpage.

So can any one provide the solution for this so that I can pass the colon in query string and when Page will be redirect without 404 error.

Solution would be much appreciated.

like image 522
cool_taps Avatar asked Nov 21 '25 18:11

cool_taps


1 Answers

When you build the URL that you redirect to, you need to encode special characters by using the UrlEncode-method:

var redirectTo = "/mypage.aspx?id=" + HttpUtility.UrlEncode("id123:456");

This will create a query string that looks like this and will be interpreted correctly:

"/mypage.aspx?id=id123%3A456"
like image 147
Markus Avatar answered Nov 24 '25 08:11

Markus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!