【发布时间】:2014-12-27 11:34:47
【问题描述】:
我在我的项目中使用 MVC5 路由属性。
我在主页上有搜索控件。当用户点击搜索按钮时,控制值将被传递给搜索控制器动作。
使用 MVC5 之前的路由属性 URL 是 http://localhost:5344/Search/View1?City=XYZ&Cat=ABC
家庭控制器代码:
public ActionResult IndexFront(string City, string Search, string hidCategory, string btnSubmit)
{
return RedirectToAction("View1", "Search", new { CityS = City, SearchS = Search, Cat = hidCategory });
}
搜索控制器代码:
[Route("Search/{CatS}/{CityS}/{SearchS?}", Name="SearchWithCityCat")]
public ActionResult View1(string CityS, string SearchS, string CatS)
{
var searchModel = new SearchModel();
return View(searchModel);
}
使用路由属性装饰 View1 并单击搜索按钮后,它显示相同的 URL 并给出错误“找不到页面”。
我没有找到解决这个问题的方法。
我做得对吗?
请帮忙。提前致谢。
【问题讨论】:
-
试试
return RedirectToAction("SearchWithCityCat", "Search",
标签: c# asp.net-mvc-4 routing asp.net-mvc-routing url-routing