c# - Best practices for base controller -


in old days when asp.net webforms developer used create basepage , in there used put common methods , properties used in application, every page inherit page.

i wonder how mvc 4, there guideline, or create base controller class , inherit controllers class?

what put in base controller class?

thanks

i avoid using base controller (inheritance) problem, because kinda smells. sure controllers need common methods , properties? @ least of functionality can implemented extension methods on controller type.

also other functionality might more suitable service injected controller. common methods require (request)state prefer service approach.

it's possible @ least functionality belong action filter (checking rights, setting user profile, handling exceptions ;) etc ).

as thumb rule, try avoid using inheritance controllers. controllers should simple can , utility behavior i'd need, try encapsulate in 1 of ways presented above.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -