วันพุธที่ 9 มิถุนายน พ.ศ. 2553

How to set default route to Area

Is simple by open your {AreaName}AreaRegistration.cs

and use (Example I add Install Area and need it default page.)

public override void RegisterArea( AreaRegistrationContext context )
{
//context.MapRoute(
// "Install_default",
// "Install/{controller}/{action}/{id}",
// new { action = "Index", id = UrlParameter.Optional }
//);

context.MapRoute(
"Install_default",
"{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional, controller = "Install" },
new { controller = "Install" }
);
}

No need to change other.

ref url is http://stackoverflow.com/questions/2140208/how-to-set-a-default-route-to-an-area-in-mvc

ไม่มีความคิดเห็น: