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

  • Home
  • SEARCH
  • 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 6023409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:00:02+00:00 2026-05-23T04:00:02+00:00

I understand MVC is all about putting things in the correct place and the

  • 0

I understand MVC is all about putting things in the correct place and the logic where it should be. My controller actions are getting filled up with business logic (not related to data storage) and I feel that I should start moving some of the logic to a different place.

Is there a convention for where I should place this logic? For example I have the following controller that’s located in the controllers file:

adminPowerController 

  public ActionResult Create(string test1)
    // business logic
    // business logic
    // business logic
    return View();
  }
  public ActionResult Index(string test1)
    // business logic
    // business logic
    // business logic
    return View();
  }
  • 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-23T04:00:04+00:00Added an answer on May 23, 2026 at 4:00 am

    The recommended place to put business logic is into a service layer. So you could define an interface which will represent the business operation:

    public interface IMyService
    {
        DomainModel SomeOperation(string input);
    }
    

    and then have an implementation of this service. Finally the controller will use it:

    public class MyController: Controller
    {
        private readonly IMyService _service;
        public class MyController(IMyService service)
        {
            _service = service;
        }
    
        public ActionResult Create(string input)
        {
            var model = _service.SomeOperation(input);
            var viewModel = Mapper.Map<DomainModel, ViewModel>(model);
            return View(viewModel);
        }
    }
    

    and configure your DI framework to pass the proper implementation of the service into the controller.

    Remark: In the example I provided I used AutoMapper to convert between a domain model into a view model which is passed to the view.

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

Sidebar

Related Questions

I am newish to MVC and understand all the great things about it, including
First of all, I do understand, that MVC 3 default template's Content folder is
As I understand it, in ASP.NET MVC a httprequest is mapped to a controller/action.
As I have understood MVC, the logic for the model should also go into
In my ASP.NET MVC application, I have a project that contains all the business
I understand that the AntiForgeryToken feature in ASP.NET MVC does prevent cross-site attacks. However,
As I understand it, MVC introduced AsyncController specifically to handle the issue of avoiding
i'm new to zend and i almost understand how it works with the mvc,
Well I am trying to learn the java MVC pattern, but I can't understand
We're working on a .NET MVC mobile site. I understand that on the iPhone,

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.