asp.net mvc 4 - ASP MVC default route is not applying for root site url -


i'm having trouble getting asp.net mvc serve default controllers index view root site url http://mysite:8080/. 404 the resource cannot found. works fine if specify full route path in url : http://mysite:8080/default/index, however, want default route apply if user doesn't specify route path though. seems should work out of gate. fresh project vs2013 mvc 4 template.

i've tried both route mappings below , neither seems work. how can achieved?

routes.maproute(     "root",     "",     new { controller = "defaultcontroller", action = "index" } );  routes.maproute(     name: "default",     url: "{controller}/{action}/{id}",     defaults: new { controller = "defaultcontroller", action = "index", id = urlparameter.optional } ); 

here solution problem. it's disappointing default route's defaults not apply root site url though.

routes.add(new route("", new siterootroutehandler("~/default/index")));  public class siterootroutehandler : iroutehandler {     private readonly string _redirecturl;     public siterootroutehandler(string redirecturl)     {         _redirecturl = redirecturl;     }      public ihttphandler gethttphandler(requestcontext requestcontext)     {         return new siteroothandler(_redirecturl);     } }  public class siteroothandler: ihttphandler {     private readonly string _redirecturl;     public siteroothandler(string redirecturl)     {         _redirecturl = redirecturl;     }     public bool isreusable     {         { return true; }     }      public void processrequest(httpcontext context)     {         context.response.redirectpermanent(_redirecturl);     } } 

Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -