简体   繁体   中英

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.

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!

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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