开发者

Where to store methods in MVC projects

开发者 https://www.devze.com 2023-04-10 12:47 出处:网络
In MVC3, where is the bes开发者_如何学Got place to store methods I am currently racking up quite a bit of code in my HomeController and feel that my methods should be seperate from the controller log

In MVC3, where is the bes开发者_如何学Got place to store methods

I am currently racking up quite a bit of code in my HomeController and feel that my methods should be seperate from the controller logic.

Should I create a model with a class of "HomeControllerMethods" or something?


Definitely do not put them inside your controllers if they are not specific to a controler and if they don't use the properties or methods of that controller.

Put them some other place. Where you need to put them is up to you. I always create another project called MyApp.Infrastructure.


Here is an answer https://codereview.stackexchange.com/questions/981/not-feeling-100-about-my-controller-design discussing a similar topic.

Another great resource is www.tekpub.com I've just gone through the ASP.NET MVC3 Real World series. This series goes along at a cracking pace, and Rob uses an Infrastructure folder similar to @tugberk's advice.


Well, application architecture is your own choice which must be dictated by your conrete use cases. Try reading about three tier pattern to begin with

0

精彩评论

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