Get current ApplicationId in ASP.NET MembershipProvider

I use MemberhipProvider and due to the way I configured it in combination with some user security, I need to get the ApplicationId (Guid) of the current application. It is easy to get the application name using Membership.ApplicationName, but I have not found an easy way to get the identifier.

+5
source share
2 answers

I believe that you will need to write your own code (e.g. a custom stored procedure) to get the identifier. This data is intended for private use by the embedded implementation of the membership provider and is not part of the provider interface (i.e., it may not exist in some provider implementations). The same goes for user ID. The good news is that storing a stored procedure for a default implementation is pretty straightforward.

You just need to:

SELECT ApplicationId FROM aspnet_Applications 
WHERE ApplicationName = 
    (System.Web.Security.Membership.Provider.ApplicationName 
        from the ASP.NET code)

You might want to rethink if you really need this identifier.

+6
source

SQLMembership , . aspnet_Applications_CreateApplication, @ApplicationName (input), @ApplicationID (output) , .

0

All Articles