Set active membership provider programmatically

↘锁芯ラ 提交于 2019-12-12 01:56:31

问题


I have a web application with custom membership providers. The provider I want to use connects to a Progress database.

I have one page that uses a competely different membership provider. I've tried setting this via the web.config but cannot get it working.

So I was wondering if I could set the membership provider programmatically for this page. I see here that it is possible on some level though this looks pretty hacky. I was hoping there'd be a clean way of doing this one way or another. Everything else on SO or the wider web seems to end in a dead end. This suggests to me that what I'm attempting is not possible but it would be nice to know either way.

Is it possible to simply switch the MembershipProvider at runtime?


回答1:


This is not an ideal solution but you can select a different provider at runtime.

var p = (ProgressMembershipProvider)Membership.Providers["ProgressProvider"];
var user = p.GetUser("Foo", true);


来源:https://stackoverflow.com/questions/10496647/set-active-membership-provider-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!