ASP.NET MVC controller actions design

后端 未结 4 1842
无人共我
无人共我 2020-12-30 09:51

I really like the way ASP.NET MVC works. I\'d love to implement it on all new web projects moving forward, but I hit a snag in a prototype the other day that I really haven\

4条回答
  •  萌比男神i
    2020-12-30 10:37

    One mistake that newcomers to MVC make is to group actions into a controller for display reasons. In your case, instead of grouping the Register and ThankYou actions in with the homepage try separating them out into an AccountController as the MVC team has done in the sample project. You can use routing to set the Url's up however you want for the end-user.

    As for your other actions, how about a ReportController? You could then additionally have an AdministrationController whose Index action/view contains links to various admin actions, including those on the ReportController.

    Short Version: Group actions into a controller by function, not site navigation.

提交回复
热议问题