c# - When OnAuthorization method is called? -


i have implemented custom method making user information available views smth that:

    protected override void onauthorization(authorizationcontext filtercontext)     {         if (httpcontext.user != null)         {             httpcookie authcookie = request.cookies[formsauthentication.formscookiename];             if (authcookie != null)             {                 formsauthenticationticket authticket = formsauthentication.decrypt(authcookie.value);                 javascriptserializer serializer = new javascriptserializer();                 awesomeuser user = serializer.deserialize<awesomeuser>(authticket.userdata);                 if (user == null)                 {                     httpcontext.user = null;                 }                 else                 {                     httpcontext.user = new platformuser(typeof(dbmembershipprovider).name, user);                 }             }             else             {                 httpcontext.user = null;             }          }         base.onauthorization(filtercontext); } 

the problem when user information (especially permissions) changed in db not reflected in views. shall update on every call here on there smarter way, i.e. other method helps update user information automatically?

onauth method called when process requests authorization.

you find lot of material online, adding few of them here

http://blog.tomasjansson.com/securing-your-asp-net-mvc-3-application http://schotime.net/blog/index.php/2009/02/17/custom-authorization-with-aspnet-mvc/

http://patrickdesjardins.com/blog/make-all-actions-of-controller-securized-with-authorise-filter-implicit


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -