开发者

Is there a way to call custom method of Custom Role Provider class

开发者 https://www.devze.com 2022-12-27 13:08 出处:网络
I have created my own custom role provider class \"SGI_RoleProvider\" and configured properly. Everything is working fine.

I have created my own custom role provider class "SGI_RoleProvider" and configured properly. Everything is working fine.

Suppose that I have added a public method say "SayHello()", then how can i call that. Because if i am using Roles then the method is not displayed. If i am forcefully using that Rol开发者_如何学编程es.SayHello() then compiler gives the error.

Any suggestion how can i call this. Because creating a new instance of SGI_RoleProvider is meaningless.

Thanks for sharing your time.


var myProvider = Roles.Provider as SGI_RoleProvider;
myProvider.SayHello();

Supposing you have correctly defined your provider as the default Provider


Maybe you can do something like

((SGI_RoleProvider)Roles.Provider).SayHello();

One line syntax does it all.

0

精彩评论

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