简体   繁体   English

ASP.NET Membership Provider:动态设置应用程序名称

[英]ASP.NET Membership Provider : set Application Name dynamically

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. 我正在创建一个WCF服务,以使用ASP.NET成员资格提供程序在多个应用程序(网站,WS,iPhone应用程序等)之间共享所有成员资格操作(例如用户创建,登录,更改密码等)。

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? 我想知道动态设置Membershio提供者的应用程序名称以便将此信息存储在成员资格表中是否有意义? 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. 通常,据我所知,应用程序名称来自Web.config(但在我的场景中,它始终是WCF相同),而且我还没有看到动态设置此属性的任何示例。

Another option would be to store this info in a separate table and leave the Application Name static coming from web.config. 另一个选择是将此信息存储在单独的表中,并使来自Web.config的应用程序名称保持静态。

Any suggestion is welcome! 任何建议都欢迎!

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. 应用程序名称允许多个应用程序共享同一数据库,但保持用户隔离-配置了app1应用程序的网站将不会与用户共享app2应用程序,即使它们共享相同的物理成员数据库。

Log it elsewhere! 在其他地方登录!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM