wif - How do I move federationConfiguration out of web.config and to some custom config file and load it dynamically by code -
i have configuration in web.config , works fine.
<configuration> <system.identitymodel.services> <federationconfiguration> .... </federationconfiguration> </system.identitymodel.services> </configuration> how move out of web.config custom config file , load code?
i want utilize same construction of configuration not have alter in code if have alter configuration file.
you can tap wif event global.asax
void application_start(object sender, eventargs e) { // code runs on application startup federatedauthentication.federationconfigurationcreated += federatedauthenticationonfederationconfigurationcreated; } in handler can adapt configuration @ runtime. here code give idea. end code more complex.
private void federatedauthenticationonfederationconfigurationcreated(object sender, federationconfigurationcreatedeventargs args) { var identityconfiguration = new identityconfiguration(loadconfig:false); identityconfiguration.securitytokenhandlers.clear(); //... identityconfiguration.securitytokenhandlers.add(new saml2securitytokenhandler()); //... var configuration = new federationconfiguration(loadconfig: false) { cookiehandler = new chunkedcookiehandler(), //... identityconfiguration = identityconfiguration }; args.federationconfiguration = configuration; } if have doubts on value give object, can temporarily switch configuration , inspect runtime values through same event. don't underestimated complexity , richness of configuration delivered wif out of box. in general, migth want mixture of "code config" , "web.config config" web.config still used configure more variable parts of config , code used more unchangable pieces...
wif claims-based-identity federated-identity ws-federation
No comments:
Post a Comment