更改Microsoft.IdentityModel配置

编程入门 行业动态 更新时间:2024-10-20 07:38:30
本文介绍了更改Microsoft.IdentityModel配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好,我想以编程方式添加位于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配置

本文发布于:2023-11-13 00:18:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582887.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Microsoft   IdentityModel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!