Should controllers in an ASP.NET MVC web app call repositories, services, or both?

后端 未结 7 1453
生来不讨喜
生来不讨喜 2021-01-30 09:22

The controllers in my ASP.NET MVC web app are starting to get a bit bloated with business logic. The examples on the web all show simple controller actions that simply pull dat

7条回答
  •  故里飘歌
    2021-01-30 10:18

    It would help if we could stop seeing this example over and over again ...

    public ActionResult Index()
    {
      var widgetContext = new WidgetDataContext();
      var widgets = from w in widgetContext.Widget
                    select w;
      return View(widgets);
    }
    

    I do realize that this isn't helpful to your question but it seems to be part of a lot of demo-ware that I think can be misleading.

提交回复
热议问题