How can I host a asp.net MVC web app in a sub folder?

Discussion in 'General troubleshooting' started by peterheard01, Jun 11, 2013.

  1. Hi I'm trying to get some MVC apps hosted in subfolders on my main site im really struggling to get ANYTHING from the guys on support :-(

    So I wanted to have....

    Root_Folder/Site1
    Site2
    Site3

    I have purchased the domain name

    site1.co.uk
    site2.co.uk
    site3.co.uk

    Andy they all point to that folder (I know this and have tested it)

    I want to have 3 MVC applications that work the following way.....

    site1.co.uk/home/index
    site2.co.uk/home/index
    site3.co.uk/home/index

    I have a standard aspx file in the Root_Folder that has redirect on it so....

    if (Request.Url.AbsoluteUri.Contains("site1.co.uk"))
    {
    Response.Redirect("/site1/home/index");
    }
    else if (Request.Url.AbsoluteUri.Contains("site2.co.uk"))
    {
    Response.Redirect("/site2/home/index");
    }
    else if (Request.Url.AbsoluteUri.Contains("site3.com"))
    {
    Response.Redirect("/site3/home/index");
    }

    It redirects me okay to the following url

    http://site1.co.uk/site1/home/index

    But I just CANNOT get the MVC site to load I just get a directory listing or a 404!

    I have added the route...

    routes.MapRoute(
    name: "Default",
    url: "site1/{controller}/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );

    To the sub applications but that doesnt help.

    Can someone give me a nudge as to how to set up MVC as sub-applications?
     
  2. Ray

    Ray

    This is a standard Redirect Script, something as sophisticated as MVC, may require a little more complex such as using the IIS URL Rewrite module.
     

Share This Page