ASP.NET MVC5路由错误:对一个操作有效,但对另一个操作无效
我有3个动作;类别、标记和搜索具有相同类型的路由签名,但路由以不同的值开始 现在,只有这一类工作正常,但其他两类工作不正常 搜索操作在url和页面加载中显示:ASP.NET MVC5路由错误:对一个操作有效,但对另一个操作无效,asp.net,asp.net-mvc,razor,Asp.net,Asp.net Mvc,Razor,我有3个动作;类别、标记和搜索具有相同类型的路由签名,但路由以不同的值开始 现在,只有这一类工作正常,但其他两类工作不正常 搜索操作在url和页面加载中显示:localhost/Search?s=SOMEWORD 但是标记操作给了我一个错误:您正在查找的资源已被删除、名称已更改或暂时不可用。 我希望我的路由是localhost/{action}/{someWord},但不能 控制器操作: public ActionResult Category(string category, int p =
localhost/Search?s=SOMEWORD
但是标记操作给了我一个错误:您正在查找的资源已被删除、名称已更改或暂时不可用。
我希望我的路由是localhost/{action}/{someWord}
,但不能
控制器操作:
public ActionResult Category(string category, int p = 1)
{
//some caculations
return View("List", viewModel);
}
public ActionResult Tag(string tag, int p = 1)
{
//some caculations
return View("List", viewModel);
}
public ActionResult Search(string s, int p = 1)
{
//some caculations
return View("List", viewModel);
}
路线图:
routes.MapRoute(
"Category",
"Category/{category}",
new { controller = "Blog", action = "Category" }
);
routes.MapRoute(
"Tag",
"Tag/{tag}",
new { controller = "Blog", action = "Tag" }
);
routes.MapRoute(
"Search",
"Search/{s}",
new { controller = "Blog", action = "Search" }
);
您可以尝试使用URL:localhost/Search?s=SOMEWORDnot我不希望我的URL是:localhost/Search/Someword。。再次,标记操作不起作用。