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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:40:18+00:00 2026-06-07T11:40:18+00:00

It would be great if someone could help me on this problem as I

  • 0

It would be great if someone could help me on this problem as I am new to web development and ASP.NET MVC. My goal is to design an MVC application which could help users to create their own mini websites. Each user will get their own mini websites and an admin panel to change the pages and template of their sites. I think there are scripts out there to achieve something similar, but we need to create our own for our specific requirements
Towards that goal I created a main mvc 3 application and I created an area as Site under it. We want the user to have their own sub domain urls like http://www.site1.mainsite.com where site1 is the name of the mini site of the user. For that I added 2 routes one for the main site and another for the area like

routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            new[] { "MainSite.UI.Controllers" }
        );

In Area Registration

context.MapRoute(
            "Sites_default",
            "{controller}/{action}/{id}",
            new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            new {controller = new SiteConstraint()},
            new[] { "MainSite.UI.Areas.Site.Controllers" });

Both of them have the same url type, but area route have a constraint where I added like

var url = httpContext.Request.Headers["HOST"];
        var storeName = url.Split('.')[1];
        var match = storeName != "mainsite";
        return match;

so far its working, But i dont think its a good design. Now apart from this I need to add 2 more areas one is siteadmin and another is blog.
What should be best way to achieve this?

  • sub domain urls should be directed to area “site”
  • subdomain url/Admin should be routed to area “siteadmin”
  • domain/blog should be routed to blog area.
  • domain other urls should be handled by main controllers

Thanks in advance

  • 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-07T11:40:19+00:00Added an answer on June 7, 2026 at 11:40 am

    I didnt get even one reply 🙁 But I tried playing with the routes and achieved some what near to what I was looking for.
    Thanks to Route Debugger, It helped me to see what was going wrong with the routes

    When I tried adding another area “Admin”, and registered it with the route below

    context.MapRoute(
                "SiteAdmin_default",
                "Admin/{controller}/{action}/{id}",
                new { controller = "Dashboard", action = "Index", id = UrlParameter.Optional },
                new { controller = new SiteConstraint() },
                new[] { "MainSite.UI.Areas.SiteAdmin.Controllers" }
            );  
    

    Things started going wrong. Route Debugger helped to me to figure out, what was happening.
    For me the order of the Routes really mattered, so I had to make sure that my areas were registered in the correct order.

    AreaRegistration.RegisterAllAreas()
    

    was not registering my routes in the correct order, Googling gave me this helper method.

    public static class RouteHelper
    {
        public static void RegisterArea<T>(RouteCollection routes, object state) where T : AreaRegistration
        {
            var registration = (AreaRegistration)Activator.CreateInstance(typeof(T));
            var context = new AreaRegistrationContext(registration.AreaName, routes, state);
            var tNamespace = registration.GetType().Namespace;
            if (tNamespace != null)
            {
                context.Namespaces.Add(tNamespace + ".*");
            }
            registration.RegisterArea(context);
        }
    }
    

    That method helped me to register the areas in the required order in the Global asax as

     RouteHelper.RegisterArea<SiteAdminAreaRegistration>(RouteTable.Routes, null);
     RouteHelper.RegisterArea<SiteAreaRegistration>(RouteTable.Routes, null);
    

    I am writing it down, what I got so far as an answer so that someone else may be find it useful.

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

Sidebar

Related Questions

I was wondering if someone could help me get pointers to solve this problem.
I am pretty new to Patterns and some help would be great. I am
I would be grateful if someone could help me out here. I'm just starting
I created a simple .NET COM activex and it would be great if it
A simple answer to this super simple question would be great! Here is the
I'm just switching from Emacs to IDEA and it would be a great help
What would you recommend for modular development in Java. OSGI is great but it's
My problem is not so much a programming question but figured someone here could
I've done some research online with this problem, and i'm totally confused. If someone
Can someone help me improve on this? There has to be a better way.

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.