ASP.NET Membership Provider:动态设置应用程序名称
我正在创建一个 WCF 服务,以使用 ASP.NET 会员资格提供程序在多个应用程序(网站、WS、iPhone 应用程序等)之间共享所有会员资格操作(例如用户创建、登录、更改密码等)。
我还想存储有关发送请求的应用程序的信息。
我想知道动态设置 Membershio 提供商的应用程序是否有意义 命名以便将此信息存储在成员资格表中?由于提供者是单例,它会是这样的:
System.Web.Security.Membership.ApplicationName = application;
bool isValid = System.Web.Security.Membership.ValidateUser(username, password);
它实际上可以工作,但不知道这是否正确使用以及它是否会在将来造成任何麻烦。通常,据我所知,应用程序名称来自 Web.config(但在我的场景中,它始终是相同的,WCF 名称),并且我还没有看到任何动态设置此属性的示例。
另一种选择是将此信息存储在单独的表中,并将来自 web.config 的应用程序名称保留为静态。
欢迎任何建议!
I'm creating a WCF service to share all membership operations (such as user creation, login, change password, etc) between multiple applications (websites, WS, IPhone App, etc), using the ASP.NET Membership Provider.
I want also to store information about application sending the request.
I'm wondering if it make sense to dynamically set the Membershio provider's Application
Name so to store this info in the membership tables? Since the provider is a singleton it would be something like :
System.Web.Security.Membership.ApplicationName = application;
bool isValid = System.Web.Security.Membership.ValidateUser(username, password);
It actually works but don't know if this is a proper use and if it can cause any trouble in future. Usually as far as I know the application name comes from the Web.config (but in my scenario it would be always the same, the WCF one) and I haven't seen any example where this Property is dynamically set.
Another option would be to store this info in a separate table and leave the Application Name static coming from web.config.
Any suggestion is welcome!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是会员资格提供商中应用程序名称的用途。
您说您希望在多个应用程序之间共享用户帐户。在这种情况下,所有应用程序之间的会员资格申请名称必须相同。
应用程序名称允许多个应用程序共享同一个数据库,但保持其用户隔离 - 使用 app1 应用程序配置的网站不会与 app2 应用程序共享用户,即使它们共享相同的物理成员资格数据库。
将其记录在其他地方!
That's not what the application name is for in the membership providers.
You say that you want the user accounts to be shared between multiple applications. In this case the membership application name must be the same between all applications.
The app name is there to allow multiple applications to share the same database but keep their users isolated - a web site configured with an application of app1 will not share users with an application of app2 even if they share the same physical membership database.
Log it elsewhere!