Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6319203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:45:56+00:00 2026-05-24T15:45:56+00:00

I have a Service class with a method called GetProducts(). That encapsulates business logic

  • 0

I have a Service class with a method called GetProducts(). That encapsulates business logic and calls the repository to get a list of products.

My MVC view wants to show that list of products as an MVC SelectList. Where is the correct place for that logic to go. I seem to have 3 options:

  1. Model

    The Model should expose a property called ProductSelectList. When the getter of this property is called by the View, the Model should call Service.GetProducts() and convert the result to a SelectList before passing it on.

    Plausible argument: The Model should make calls to business logic and the repository. The View should merely render predetermined data. The Controller should not be involved, save for passing contextual data to the Model.

  2. View

    The View should contain code that calls Service.GetProducts() directly and converts the result to a SelectList inline.

    Plausible argument: The View should call for this data directly as it is specifically for use on the View. There is no need to involve the Model or Controller, as we are calling an abstracted Service method anyway, so anything else just adds extra overhead.

  3. Controller

    The Controller should make the call to Service.GetProducts(), convert the results to a SelectList and pass it through to the Model, which should contain a simple ProductSelectList property. The View will access this property for rendering.

    Plausible argument: The Controller knows which parameters to provide to the Service method, so it should make the call. The Model should be a simple placeholder for data, filled by the Controller. The View’s job is to simply render the data from the Model.

I have a feeling that the correct answer is Model, but the other two make some reasonable points. Perhaps I’ve muddied the waters by already having a Service class that’s separate to the Model?

Would anybody care to share their opinion? Is this just a matter of taste?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T15:45:57+00:00Added an answer on May 24, 2026 at 3:45 pm

    I personally subscribe to the logic of Number 3, allowing the controller to populate the Model (or View Model as is sometimes differentiated).

    • I have my views dumb and only displaying data.
    • I have my View Models store the information that the View will need, occasionally exposing ‘get only’ properties that format other properties into a nicer format. If my model needs access to my services, then I feel I’m doing something wrong.
    • The controllers arrange and gather all the information together (but do no actual work, that is left for the services.

    In your example, I would have my controller action similar to:

    public ActionResult Index()
    {
        IndexViewModel viewModel = new IndexViewModel();
        viewModel.ProductSelectList = new SelectList(Service.GetProducts(), "Value", "Name");
        return View(viewModel);
    }
    

    and my view model similar to:

    public class IndexViewModel()
    {
       public SelectList ProductSelectList { get; set; }
       public int ProductID { get; set; }
    }
    

    With the appropriate part of the view looking like:

    @Html.DropDownListFor(x => x.ProductID, Model.ProductSelectList);
    

    This way I’m content that I know where to look if there is an issue with anything and everything has a very specific place.

    However, there is no correct way as seems always to be the case with these things. Stephen Walther has a good blog series on MVC tips. In one he talks about the View Model emphasis and although not a SelectList he populates, the SelectList is still data in much the same way his list of products is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a service clint class that has a method called fetch. I
I have some class that I'm passing as a result of a service method,
Given that I have the following WCF service: class LookUpService { public List<County> GetCounties(string
I have a web service class that the rest of the framework depends on
I have a wcf service. The service itself (class that inherits the ServiceContract )
I currently have service classes that look something like this public class UserService :
I have a service proxy class that makes asyn call to service operation. I
I have a service class implemented in Java 6 / Spring 3 that needs
I have an AsyncTask which calls my LocationHandler class method getLocation() which runs a
I have A WCF service that has a class that inherits System.Web.Security.RoleProvider. In this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.