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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:55:52+00:00 2026-06-06T18:55:52+00:00

Platform: ASP.NET 4.0, MVC 4 RC, VS 2012 Update: I’ve answer my question, myself.

  • 0

Platform: ASP.NET 4.0, MVC 4 RC, VS 2012

Update: I’ve answer my question, myself. Please see my answer post below

What I want to do:

I currently have a site called http://www.a.com which targets a specific customer segment. I want to create a variant called http://www.b.com which targets a different segment.

However, in the background, the technology and code for a and b will be the same for most parts, with only some pages / content different depending on whether the user is browsing using domain a or b. It makes absolutely no sense for me to create a new project for this purpose.

However, it’s not at all clear to me how I should implement http://www.b.com and it’s flow in MVC. How to render a different homepage when someone comes from http://www.b.com, goes through many pages which are the same as http://www.a.com but some rendered different depending on whether the URL is for a or b.

Some pointers, hints, examples greatly appreciated.

Update: I’ve answer my question, myself. Please see my answer post below

  • 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-06-06T18:55:55+00:00Added an answer on June 6, 2026 at 6:55 pm

    Here’s what I finally did

    First, thanks to those that answered my post, you helped me think through what I could do. In the end, what I did was a fairly simple sequence of things. Here’s how:

    1. I pointed my new domain http://www.b.com to my web host so typing http://www.b.com would point to the root of http://www.a.com (CNAME)

    2. In my solution, I did the following

    I have a BaseController that all controllers derive from, and in there I declared IsPageB

    public class BaseController : Controller
        {
            //
            // GET: /Base/
    ...
            protected bool IsPageB = false;
    ....
        }
    

    In the BaseController, I set its value depending on host

     protected override void OnActionExecuting(ActionExecutingContext ctx)
     {           
           ...
           IsPageB =  Request.Url.Host.Contains("b.com");
           ... 
      }
    

    So in each controller, I check for IsPageB

    For e.g. In the HomePage, I simply switched view depending on this variable

    public ActionResult Index()
    {
        if (IsPageB)
            return View("B_Home");
    
        return View();
    }
    

    Inside the Views, I either use a ViewBag.IsPageB that I set in the controller, or if there’s no controller that’s generating the view, I simply set a local variable

    @{
        bool isPageB = Request.Url.Host.Contains("b.com");
    }
    

    And then generate markup based on this value.

    And it all has worked fine so far, perhaps there’s a cleverer way to do this, but for my purpose where 90% of the underlying code is same where a or b, and some output changes, this is fine. But I’m always looking for cleaner ways. For e.g. is there some way I can access the IsPageB variable in a view without using ViewBag or attaching it to a model?

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

Sidebar

Related Questions

I'm writing a simple blogging platform with ASP.NET MVC. My question is regarding forms
I have an ASP.Net MVC page where I want to use AJAX to update
I have downloaded the ASP.NET MVC 2 Release version (using Web Platform Installer) as
I'm kind of new to the .NET platform. And currently I'm learning ASP.NET MVC.
I am developing some REST resources using the ASP.NET MVC 3 platform. So far,
Currently we are migrating an existing asp.net web application to asp.net mvc 2 platform.
I am new to asp.net mvc platform. I'm developing with razor template engine in
I recently installed ASP.NET MVC 3 via web platform installer. I don't have the
Why must IE be so difficult? Building site on ASP.NET MVC platform. Email page
Before you answer, this question is complicated: We are developing in asp.net / asp.net

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.