How to get "return url" in Janrain RPX
How to get the previous url using the Janrai开发者_运维知识库n RPX login?
I´m using Asp.Net MVC to request.
When an anonymous user browses to a secured view, asp.net will automatically redirect them to the SignIn page and place the ReturnUrl in the querystring. You can retain the ReturnUrl by appending it to the token_url used in the RPX login.
Here is the helper I created to generate the correct href for the RPX iframe on my SignIn page:
public static string RpxSignInUrl(this HtmlHelper htmlHelper)
{
string returnUrl = FormsAuthentication.GetRedirectUrl(
String.Empty, // userName (not used, but cannot be null)
false); // persistent cookie (also ignored)
string tokenUrl = "http://<your-domain>/Account/RpxResponse?ReturnUrl=" +
HttpUtility.UrlEncode(returnUrl);
string realm = "<your-app-id>.rpxnow.com";
string signInUrl = String.Format(
CultureInfo.InvariantCulture,
"http://{0}/openid/embed?token_url={1}",
realm,
HttpUtility.UrlEncode(tokenUrl));
return signInUrl;
}
After the user authenticates, RPX will call this url which now includes the original ReturnUrl. You can use FormsAuthentication.GetRedirectUrl
again to retrieve the return url.
Note that its important to use this API rather than just getting the value from the Request.Querystring collection because it validates the return url, ensuring that its from the same domain. If the url is deemed unsafe, asp.net will fall back to the defaultUrl property specified on the forms element in your web.config.
精彩评论