0
私は名前Admin
によって面積を有し、かつAdminAreaRegistration
に私は打撃のようなルートを定義します。複数のルート登録
public class AdminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Admin";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new {Controller="Home", action = "Index", id = UrlParameter.Optional }
);
context.MapRoute(
name: "Product",
url: "Admin/ProductForm-{FormName}",
defaults: new { controller = "ProductForm", action = "Index", id = UrlParameter.Optional }
);
}
}
とProductFormController
に(Admin
領域に)私が持っている:
public ActionResult Index(string FormName)
{
return View();
}
私はこのURLに行きたい:http://localhost:5858/Admin/ProductForm-mobile
、それは(フォーム名=モバイルで)ProductFormController
でIndex
アクションにルーティングする必要がありますが、それはしませんでした。何が問題ですか?
? –
@CristianSzpisjakは '404'エラーを返します – pejman
' Admin_defaut'ルートを最後に置きます。デフォルトルートは常に最後のルートにする必要があります。 –