Problem Routing domains subfolder

Posted by hkda150 on Stack Overflow See other posts from Stack Overflow or by hkda150
Published on 2010-03-27T19:24:42Z Indexed on 2010/03/27 20:13 UTC
Read the original article Hit count: 226

Filed under:
|

Hi there,

I'm pretty new to ASP.NET MVC and I hope it is not a too silly question. So here it comes.

I have ...

My problem...

  • The problem for me is the routing of my application (it worked fine without using a subfolder after the domain-name). The applications homepage loads not to bad, with css files but without ressources like images (defined in css files) and without jQuery ajax calls similar to /mycontroller/myaction
  • links are only working once (the second time I get a page similar to this link: http://mydomain/mysubfoler1/myappfolder/myController/myController/myAction)

Here's my Global.asax contaning the routing:

public static void RegisterRoutes(RouteCollection routes)

{

    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.MapRoute(    
        "Default",
        "{controller}/{action}/{id}",
        new { controller = "myController", action = "Index", id = "" }
        defaults    
    );

    routes.MapRoute(    
        "Root",
        "",
        new { controller = "myController", action = "Index", id = "" }   
    );    
}

protected void Application_Start()    
{    
    ViewEngines.Engines.Clear();
    ViewEngines.Engines.Add(new MyApplicationWeb.LocalizationWebFormViewEngine());
    RegisterRoutes(RouteTable.Routes);
    //RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
}

Any suggestions? My first suggestion was to use areas like:

"mysubfolder1/myappfolder/{controller}/{action}/{id}"

(but without any luck)

Thank you very much for your help!

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about routing