vb.net - ASP.NET membership check if a user is in a role in custom class -


in vs solution, have 2 projects.one web interface, other dataacess , businesslogic. know can check if logged-on user employee in web interface project code behind:

dim isemployee = user.isinrole("employee") 

the problem have class call usermanagement in da , bl project want check logged-on user role also. can't use dim isemployee = user.isinrole("employee") because doesn't have aspx page.

what need check user role in custom class?

thank you.

you need reference system.web in business project. following:

    dim context system.web.httpcontext = system.web.httpcontext.current     dim isrole boolean = context.user.isinrole("admin") 

or c#

system.web.httpcontext context = system.web.httpcontext.current; bool isrole = context.user.isinrole("admin"); 

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -