Why controllers in ASP.NET mvc RC2 partial classes and all action methods are virtual

I am creating a production system using ASP.NET MVC 1, and now I play and prepare the conversation for the second installment.

One of the features that I cannot understand is why all the controllers and actions went through partial and virtual strong>.

This question is likely to appear in the Q & A round, and I have no answer to it. Therefore, please, if someone knows that this is done, share your knowledge with me.

+4
source share
2 answers

They are declared partial for the purpose of expansion.

Each group of controller actions (for one controller) can, for example, be contained in a separate file. This can improve maintainability of the source code.

A good example of using partial classes is the Telerik MVC Extensions project example.

+2
source

They didn’t have (AFAIK). Perhaps you are using T4MVC (which converts controllers into partial actions and actions into virtual ones)?

Edit: oops. I just remembered that I still have RC1. Please ignore my answer if this is a problem on RC2.

Hurrah!

+1
source

Source: https://habr.com/ru/post/1301569/


All Articles