您好,我想以编程方式添加位于web.conf文件中的Microsoft.IdentityModel配置,并将其从web.conf文件中删除,因为它不是静态的。什么类必须我实现这样做了吗?谢谢。
Hello,I want to add the configuration of Microsoft.IdentityModel which is located in the web.conf file programmatically and delete it from the web.conf file because it's not static.What class must I implement to do that?Thanks.
推荐答案
你想要有多动态更改配置的条款?每次初始化,或者每次请求?从你提到web.config的事实来看,我假设你正在实现一个ASP.Net网站?如果是这样,您可以将global.asax添加到您的网站,并添加以下行: 无法Application_Start(对象发送者,EventArgs e) {联合身份验证.ServiceConfigurationCreated + = new EventHandler< ServiceConfigurationCreatedEventArgs>(FederatedAuthentication_ServiceConfigurationCreated); }
Hi, How dynamic do you want to be in terms of changing the config? Per initialization, or maybe per request? Judging by the fact that you mentioned web.config, I am assuming you are implementing an ASP.Net website? If so, you can add a global.asax to your website, and add the following lines:void Application_Start(object sender, EventArgs e) { FederatedAuthentication.ServiceConfigurationCreated += new EventHandler<ServiceConfigurationCreatedEventArgs>(FederatedAuthentication_ServiceConfigurationCreated);}
void FederatedAuthentication_ServiceConfigurationCreated(object sender,ServiceConfigurationCreatedEventArgs e) { //您可以配置ServiceConfiguration通过访问e.ServiceConfiguration 上面的方法将允许您在初始化期间(而非每个请求)配置web.config中microsoft.identityModel部分中几乎所有内容, federatedAuthentication元素的例外。这将采取不同的方法。 谢谢, 丹尼尔
void FederatedAuthentication_ServiceConfigurationCreated(object sender, ServiceConfigurationCreatedEventArgs e){ // you can configure ServiceConfiguration by accessing e.ServiceConfiguration}The above method will allow you to configure almost everything that you could in microsoft.identityModel section in your web.config during initialization (not per request), with the exception of the federatedAuthentication element. That will have to take a different approach.Thanks,Daniel
更多推荐
更改Microsoft.IdentityModel配置
发布评论