开发者

Access ASP.Net rolesprovider from external assembly

开发者 https://www.devze.com 2023-02-03 23:52 出处:网络
I have a RolesProvider properly registered and functioning. When the ASPX-page is executed I do some of the work in external assemblies 开发者_运维百科(.dll-files referenced in, plain vanilla).

I have a RolesProvider properly registered and functioning. When the ASPX-page is executed I do some of the work in external assemblies 开发者_运维百科(.dll-files referenced in, plain vanilla).

I need to access methods on this role provider from the external assembly. How can I do that?

Note: I don't want to pass a reference from ASPX to the external class if possible. Something like "HttpContext.Current.Roles" would be great.

Bonus: Shed some light on when and how is the custom ASP.Net RoleProvider used.


You just access the static Roles class which lives in the namespace System.Web.Security. Remember to add a reference to System.Web.dll as well in your external project.

http://msdn.microsoft.com/en-us/library/system.web.security.roles(v=VS.100).aspx

Manages user membership in roles for authorization checking in an ASP.NET application. This class cannot be inherited.

0

精彩评论

暂无评论...
验证码 换一张
取 消