有没有办法像这样定义路线
routes.MapRoute(
name: "Language",
url: "{controller}/{action}.{culture}",
defaults: new { controller = "Home", action = "Index", culture = UrlParameter.Optional }
);
能够像http://www.domain.com/Test/Create.us-US一样处理网址吗?
答案 0 :(得分:0)
是的,你可以这样做,但是为最后没有点的http://www.domain.com/Test/Create添加网址
routes.MapRoute(
name: "Language",
url: "{controller}/{action}",
defaults: new { controller = "Home", action = "Index", culture = "us-US" }
);
答案 1 :(得分:0)
没有你可以创建没有点的路线,但你使用特殊的字符到根。当我们在那时在控制器处声明方法时,您可以在路径
中指定动作名称defineroutes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "DashboardV1_bm", id = UrlParameter.Optional }
);
[HttpPost, ActionName("DashboardV1_bm")]
[ValidateAntiForgeryToken]
public ActionResult DashboardV1(int id)
{
Shift shift = db.Shifts.Find(id);
db.Shifts.Remove(shift);
db.SaveChanges();
this.AddToastMessage("Delete", "Record is successfully deleted !", ToastType.Success);
return RedirectToAction("Index");
}
有关详细信息,请访问我的博客: http://programmingcode.in/create-routemap-to-access-new-created-view-page-in-mvc-dot-net/