ASP.NET MVC Default URL View

后端 未结 4 1925
孤独总比滥情好
孤独总比滥情好 2020-12-15 23:06

I\'m trying to set the Default URL of my MVC application to a view within an area of my application. The area is called \"Common\", the controller \"

4条回答
  •  轮回少年
    2020-12-15 23:44

    What you have to do is:

    • Remove Default Route from global.asax.cs

      //// default route map will be create under area
      //routes.MapRoute(
      //    name: "Default",
      //    url: "{controller}/{action}/{id}",
      //    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
      //);
      
    • Update SecurityAreaRegistration.cs in area Common

    • Add following route mapping:

       context.MapRoute(
          "Default",
          "",
          new { controller = "Home", action = "Index", id = "" }
      );
      

提交回复
热议问题