Should an MVC Controller and View have a 1 to 1 relationship?

I am currently using asp.NET MVC to build a Content Management System parts of a website and have the odious job of recreating all of my Views as Partial Views as it appears to be breaking the way the site map works.

For example, my FAQAdminController has the Views: Index, AddFAQ, EditFAQ, ConfirmDeleteFAQ and these have to become partial views.

I have been told that each Controller should have a single View and all other forms or actions that end in page content to be displayed should be implemented as Partial Views.

I have checked before posting and no documentation, articles, wikis or SO questions give me a straight answer as to whether or not having multiple Views per Controller is breaking the MVC model.

Strictly, should an MVC Controller and View have a 1 to 1 relationship?


I have been told that each Controller should have a single View and all other forms or actions that end in page content to be displayed should be implemented as Partial Views.

That's nonsense.

Strictly, should an MVC Controller and View have a 1 to 1 relationship?

Absolutely not. Design your application in a logical and consistent way.

A controller usually handles many actions and returns many different views. You could consider having a FAQController to render all the views, for both user and admin.


I think that defeats the purpose of MVC. As controller should be able to decide which view to use to present model.


MVC控制器应该能够支持多个View。

链接地址: http://www.djcxy.com/p/5114.html

上一篇: 什么是控制反转?

下一篇: MVC控制器和视图应该有1对1的关系吗?