Created
July 19, 2012 22:43
-
-
Save sandrinodimattia/3147378 to your computer and use it in GitHub Desktop.
MVC Application w/ dynamic realm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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