Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In my base controllers I actually put some utility method (<code>[NonAction]</code>) collected over time. I prefer to add functionalities to Controllers by decorating with Attributes if possible. </p> <p>Lately my base controller has:</p> <ul> <li>some Properties for retrieving information about the current user (my app specific informations, not the User.Identity stuffs)</li> <li>A simple <code>protected override void OnException(ExceptionContext filterContext);</code> override for at least logging unhandled exception and have some sort of automatic notifications</li> <li>A bunch of Cookies related methods (WebForms auth cookies management for example)</li> <li>A bunch of usefull standard attributes (usually <code>[Authorize]</code>, <code>[HandleError]</code>, <code>[OutputCache]</code>) in its declaration.</li> <li>some standard method for preparing widely used json data types on the fly (when possible I prefer to have a standard json object with ErrorCode, ErrorMessage and a UserData).</li> </ul> <p>With time you'll find more and more utilities to keep with your controllers, try to keep an assembly with the simpler ones (avoiding heavy dependencies), will come handy with your next MVC projects. (the same goes for Helpers and to some degree also for EditorTemplates).</p> <p>For the Authorize Attribute part, well, I think the cleanest way is to write your own <code>AuthorizeAttribute</code> class, specifically a <code>NonAuthorizeAttribute</code>. I think I've also seen it somewhere on SO.</p> <p>You can also play with the <code>Order</code> Property of the default <code>AuthorizeAttribute</code> - put different Order in BaseController and in Action, in order to have Action's one executed first, but I cannot recall if you can actually break the Attributes processing chain.</p> <p>Regards,</p> <p>M.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload