5

In ASP.NET, I build a string redirectURL to redirect to ADFS form with multiple query string parameters. One such complex parameter is the returnURL with multiple parameters.

My problem is that only the first parameter of the returnURL is available when it actually return.

E.g. redirectURL = <br> 
https://aaa.aaa/adfs/Form.aspx <br>
?DomainName=domain <br>
&AccountName=account <br>
&returnURL=https://bbb.bbb/MyPage.aspx?param1=111&param2=222

I know it complicates when identify the &amp symbol of actual parameters and parameters in returnURL. Please help me to fix this.

Thanks in advance.

2
  • Why are you passing a page with params to a page with params? What kind of functionality are you trying to achieve? Commented Jan 12, 2013 at 14:28
  • To build the redirectURL there's a specific method and it builds only main three parameters (DomainName, AccountName, returnURL). Then after the function at Form.aspx it again redirect to returnURL. I want two parameters in that return url. It may sounds complicated, but I hope it isn't impossible.. Pls help Commented Jan 12, 2013 at 14:38

1 Answer 1

11

You should use HttpUtility.UrlEncode when composing the link and HttpUtility.UrlDecode when resolving it.

For your case it should be something similar to:

"https://aaa.aaa/adfs/Form.aspx?DomainName=domain&AccountName=account&returnURL=" + 
    HttpUtility.UrlEncode("https://bbb.bbb/MyPage.aspx?param1=111&param2=222")

And then at the target use:

HttpUtility.UrlDecode(Request.QueryString["returnURL"])
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot. Sorry it took sometimes for me to test this implementation.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.