Skip to content

Instantly share code, notes, and snippets.

@sandrinodimattia
Created July 19, 2012 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sandrinodimattia/3147378 to your computer and use it in GitHub Desktop.
Save sandrinodimattia/3147378 to your computer and use it in GitHub Desktop.
MVC Application w/ dynamic realm
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();
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment