ich mit dem Namen Admin
einen Bereich haben, und in AdminAreaRegistration
i definieren Route wie Schlag:für mehrere Routen Registrierung in Asp.net MVC Gebiet
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 }
);
}
}
und in ProductFormController
(in Admin
Bereich) Ich habe:
public ActionResult Index(string FormName)
{
return View();
}
, wenn ich an diese uRL gehen will: http://localhost:5858/Admin/ProductForm-mobile
, es sollte den Weg nach Index
Aktion im ProductFormController
(mit Formnamen = mobilen), aber es kam nicht. Was ist das Problem?
Wo es zu Umleitungen? –
@CristianSzpisjak es gibt mir '404' eror – pejman
Put' Admin_defaut' Route zuletzt. Die Standardroute sollte immer die letzte sein. –