Skip to content

Instantly share code, notes, and snippets.

@richardneililagan
Forked from sandrinodimattia/Global.asax.cs
Created February 19, 2013 15:23
Show Gist options
  • Save richardneililagan/4986820 to your computer and use it in GitHub Desktop.
Save richardneililagan/4986820 to your computer and use it in GitHub Desktop.
public class MvcApplication : System.Web.HttpApplication
{
...
private void WSFederationAuthenticationModule_RedirectingToIdentityProvider(object sender, RedirectingToIdentityProviderEventArgs e)
{
// Get the request url.
var request = HttpContext.Current.Request;
var requestUrl = request.Url;
// Build the realm url.
var realmUrl = new StringBuilder();
realmUrl.Append(requestUrl.Scheme);
realmUrl.Append("://");
realmUrl.Append(request.Headers["Host"] ?? requestUrl.Authority);
realmUrl.Append(request.ApplicationPath);
if (!request.ApplicationPath.EndsWith("/"))
realmUrl.Append("/");
e.SignInRequestMessage.Realm = realmUrl.ToString();
}
...
}
@richardneililagan
Copy link
Author

Programatically changing the WIF Realm based on the originating domain / URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment