Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I make my ASP.NET MVC controller actions virtual?

File -> New Project for ASP.NET MVC projects used to generate controllers with virtual actions. I'm not sure if that stopped with MVC 2 or MVC 3, but is this no longer a best practice?

like image 245
kenwarner Avatar asked Jun 04 '11 16:06

kenwarner


People also ask

Should I use async controller actions?

When to use Asynchronous Controller. Asynchronous action methods are useful when an action must perform several independent long running operations. Suppose we have three operations which takes 500, 600 and 700 milliseconds. With the synchronous call, total response time would be slightly more than 1800 milliseconds.

Can action method be static in MVC?

- Action method cannot be a static method. ActionResult is a base class of all the result type which returns from Action method.

Is it necessary for the MVC controller class to inherit from the base class controller?

Standard view-based MVC controllers should inherit from Controller . In both frameworks, controllers are used to organize sets of action methods.

What is the primary purpose of using an async controller action?

Asynchronous action methods are useful when an action must perform several independent long running operations. A typical use for the AsyncController class is long-running Web service calls.


1 Answers

T4MVC Does make action methods virtual. If you are using it, it should make action methods virtual, no other way it can work

like image 181
archil Avatar answered Oct 20 '22 18:10

archil