0

I have a request to a page that looks like /doSomthing?a=that&ret=url however now i need to login so i must do something like /login?ret=/doSomthing?a=that&ret=url This doesnt work as well as one may hope so how do i correctly escape the return URL then unescape it?

I am using ASP.NET with C#

2 Answers 2

7

You should URL encode the querystring part, which can be done using the UrlEncode method of the HttpUtility class:

 HttpUtility.UrlEncode(yourString);
Sign up to request clarification or add additional context in comments.

Comments

3

You can do that by passing the target url through the UrlEncode method in the HttpServerUtility class. Example use, within a Page class:

string urlEncoded = Server.UrlEncode(this.Request.RawUrl);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.