Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current ApplicationId in ASP.NET MembershipProvider

I am using the MembershipProvider and due to the way I have set it up with in conjunction with some custom 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 found no easy way to get the Id.

like image 929
Craig Avatar asked Jun 14 '09 23:06

Craig


1 Answers

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

You just need to:

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

You may want to rethink if you really need this ID

like image 158
Stilgar Avatar answered Nov 15 '22 07:11

Stilgar