开发者

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

I have build a production system using ASP.NET MVC 1 and am now playing and preparing a talk on the second installment.

One peculiar thing that I can't comprehend is why all controllers and action methods have gone partial and virtual.

This question will surely pop-up at the Q&A round and I have no answer to it. So please if somebody knows开发者_高级运维 what this has been done please share your knowledge with me.


They are declared partial for the purpose of extensibility.

Every group of controller actions (for a single controller) can for example be contained in a separate file. This can improve maintainability of your source code.

A nice example of how the partial classes are used is in the Telerik MVC Extensions example project.


They had not (AFAIK). Are you maybe using T4MVC (which converts controllers to partials and actions to virtuals)?

Edit: ouch. I have just remembered that I have still the RC1. Please ignore my answer if this is issue on RC2.

Cheers!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜