开发者

are this is a good thing to combine the two controller class in MVC

once upon a time i read in a scottgu blog that

Every controlller class name end with suffix Controllers.

if i need a controller and i need only one actionresult their then are it is good thing that i place them in old one who already created in one.

i not tell that add them (开发者_开发问答actionresult) in existing controller. but in a mycontroller.cs i place two class.

first: - old one who my project already have second:- this is a controller i make instead of making new one.

are this work if i do this. and are it is really good practice or maybe i need another good trick to do this using existing controller instead of making new controller in new codefile.

i just talking that are it is good to use a controller instead of making two controller who have only one or two result.

tell me the way i should use to handle this situation.


In RESTful applications I tend to create as many controllers as I have identified resources in my application. So for example if you are developing a blog you could have a UsersController, PostsController, CommentsController each corresponding to the Users, Posts and Comments resources with their respective actions. Even if you have a single action inside the controller it is a good practice to have separate controller if it is representing a separate resource. So try to group your controllers and actions functionally and don't just dump everything into a single huge and unmaintainable controller just because you didn't want to create a separate one which is a matter of right clicking on the Controllers folder and choose Add Controller...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜