cool_taps
cool_taps

Reputation: 350

How to control colon (:) URL Query String?

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.

Upvotes: 3

Views: 5110

Answers (1)

Markus
Markus

Reputation: 22421

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"

Upvotes: 6

Related Questions