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 579545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:22:41+00:00 2026-05-13T14:22:41+00:00

The setup: (using Asp.Net MVC 2 RC, Entity Framework, SQL Server, VS2008) My buddy

  • 0

The setup: (using Asp.Net MVC 2 RC, Entity Framework, SQL Server, VS2008)

My buddy and I are working on a project that will have different domains pointing at it. We want to get the domain (website) out of the Request and use that to drive data. This website data needs to be part of all the controllers.

Ex. Data for domain1.website.com will
be different than data for
domain2.website.com, and those will be
different than data for website2.com.
The look of the site is the same for
all these, but the data is different.

I set up a BaseController that all my other controllers inherit from. But I don’t like it.

BaseController:

public class BaseController : Controller
{
    private Website _website;
    private readonly IWebsiteRepository _websiteRepository;

    public BaseController(IWebsiteRepository websiteRepository)
    {
        _websiteRepository = websiteRepository;
    }

    public Website CurrentWebsite { get; }
}

The problem with this is that I now need to pass an IWebsiteRepository to the base of each of my controllers:

public class BioController : BaseController
{
    private readonly IBiographyRepository _bioRepository;

    public BioController(IBiographyRepository bioRepository, IWebsiteRepository websiteRepository) 
        : base(websiteRepository)
    {
        _bioRepository = bioRepository;
    }
}

HERE ARE MY QUESTIONS

  1. Is there a better way to handle multiple domains being pointed at one project and filtering the data?
  2. Is there a better way to have the Website object in every controller?

UPDATE

Sorry, I forgot to add that in. I am already using IoC (structure map). My question is more along the lines of:

  1. Should I replace the BaseController with something else? ActionFilter?
  2. Is there a way to set it up so I didn’t have to pass the IWebsiteRepository to the base class?
  3. Is there a better way to handle the domains used for data?
  • 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-13T14:22:41+00:00Added an answer on May 13, 2026 at 2:22 pm

    I actually like the idea of injecting the repository via constructor injection. It will make testing the controllers much easier as you can simply pass in a mock repository. An alternative to this would be to use a static factory class to get the repository from a request, but using static classes makes unit testing harder.

    One improvement that I would make is to have a default constructor for your controllers that calls the constructor with parameters with null values. In your constructor with parameters, instantiate the correct repository if the supplied parameter is null. This way you don’t need to implement a controller factory to build the controllers with their parameters; the default controller factory can use the parameterless constructors and you still get the benefit of constructor injection.

     public BaseController() : this(null) { }
    
     public BaseController( IWebsiteRepository websiteRepository )
     {
         this._websiteRepository = websiteRepository ?? new WebsiteRepository();
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 545k
  • Answers 545k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer yes, the type of *result is ('cause the type of… May 17, 2026 at 8:45 am
  • Editorial Team
    Editorial Team added an answer I don't see any way to do so in the… May 17, 2026 at 8:45 am
  • Editorial Team
    Editorial Team added an answer SELECT * FROM [makes$] WHERE [Corporate Name]='Champion Enterprises, Inc.' May 17, 2026 at 8:45 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am developing a medium sized ASP.NET project using ASP.NET MVC and Entity Framework.
I am using a regular Visual Studio Setup Project to deploy my ASP.NET application.
I'm working on an asp.net-mvc project. I have an Items table and a Tags
I'm trying to get setup using the DataAnnotations validator in ASP.Net MVC 2.0 Beta,
I'm using controller's initializer to setup stuff that I will need. def initialize super()
I've got webform routing setup on my asp.net webforms 3.5sp1 project. I would like
I've developed a simple system using ASP.NET MVC and WCF for customers to register
I have an ASP.NET application that authenticates users using Ldap against active directory. This
I have created a setup project using Visual Studio 2008. After the application is
I am building a Setup Package using VS2008. This is a regular setup package

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.