设置活动成员资格提供编程 [英] Set active membership provider programmatically

查看:112
本文介绍了设置活动成员资格提供编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的成员提供一个Web应用程序。我想用提供商连接到Progress数据库。

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

我有一个使用competely不同成员提供一个页面。我有<一个href=\"http://stackoverflow.com/questions/10416027/forms-authentication-not-working-for-specific-page\">tried通过在web.config 设置这个,但不能得到它的工作。

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.

所以我在想,如果我能为这个网页编程设定的成员资格提供程序。我看到 的,它有可能在一定程度上,虽然这看起来pretty哈克。我希望有会做这种或那种方式的清洁方式。一切对SO或更广泛的网络似乎在<一结束href=\"http://stackoverflow.com/questions/10250941/set-membership-provider-to-use-a-specific-provider\">dead结束。这表明,我认为什么我尝试是不可能的,但它会很高兴知道无论哪种方式。

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.

是否可以简单地切换的MembershipProvider在运行时?

Is it possible to simply switch the MembershipProvider at runtime?

推荐答案

这是不是一个理想的解决方案,但你可以select不同的提供商在运行时。

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);

这篇关于设置活动成员资格提供编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆