You can subscribe to the ServiceConfigurationCreated event (off FederatedAuthentication) in Application_Start. From there you have programmatic access to configuration.
How can I an audience uri to AudienceUriElementCollection programmatically?
質問
I have an ASP.NET MVC application that uses WIF to set up federated authentication, if I set the audience uris in the web.config like so:
<system.identityModel>
<identityConfiguration>
<audienceUris>
<add value="https://foo.org/" />
<add value="https://bar.com/"/>
</audienceUris>
<!-- more setup -->
</identityConfiguration>
</system.identityModel>
everything works. But I would like to add additional audience uris in my C# code.
Question
How do I get hold of the AudienceUriElementCollection used by WIF?
How do I add new audience uris to it and have WIF use the new ones too?
解決 2
他のヒント
This is code i recently tried (only tested in development).
Uri uri = new Uri(HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host);
if(!FederatedAuthentication.ServiceConfiguration.AudienceRestriction.AllowedAudienceUris.Contains(uri))
FederatedAuthentication.ServiceConfiguration.AudienceRestriction.AllowedAudienceUris.Add(uri);
所属していません StackOverflow