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¶m2=222
I know it complicates when identify the & symbol
of actual parameters and parameters in returnURL
. Please help me to fix this.
Thanks in advance.
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¶m2=222")
And then at the target use:
HttpUtility.UrlDecode(Request.QueryString["returnURL"])