在 Web.Config 中以编程方式更改成员资格提供程序的属性
我的 web.config 中有以下 defaultmembership 提供程序
<add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="Another Type" passwordFormat="Hashed" />
我正在尝试以编程方式将 enablePasswordReset 从 false 更新为 true 但很挣扎..就我所知!
ConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
var section = (MembershipSection)config.GetSection("system.web/membership");
var defaultProvider = section.DefaultProvider;
var providerSettings = section.Providers[defaultProvider];
// Now what?
现在我不知道如何获取属性并更新它?非常感谢任何提示/示例。
I have the following defaultmembership provider in my web.config
<add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="Another Type" passwordFormat="Hashed" />
I am trying to update the enablePasswordReset from false to true programmatically but am struggling.. This is as far as I got!
ConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
var section = (MembershipSection)config.GetSection("system.web/membership");
var defaultProvider = section.DefaultProvider;
var providerSettings = section.Providers[defaultProvider];
// Now what?
Now I can't figure out how to get the attribute and update it? any hints / examples greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想通了
I figured it out
我建议创建一个自定义会员资格提供程序并使用其他来源进行设置。更改设置可能很危险;我认为这是一个用户公开的功能,允许管理员打开或关闭它?
如果您可以创建一个自定义成员资格提供程序,从数据库或 XML 文件中提取信息,然后允许或不允许该功能。不确定该代码到底放在哪里,这取决于您是否使用 ASP.NET 控件,或者您是否使用 API 进行自定义...
HTH。
I would recommend creating a custom membership provider and using another source for the setting. It can be dangerous to change a setting; I assume this is a user-exposed feature to allow an admin to turn it on or off?
If you can create a custom membership provider that pulls the information from the database or XML file and then allow the feature or not. Not sure exactly where to put this code, it would depend on whether you are using the ASP.NET controls, or if you are custom using the API...
HTH.