C# MVC5属性路由不工作
我正在项目中使用MVC5路由属性 我在主页上有搜索控件。当用户单击搜索按钮时,控制值将传递给搜索控制器操作 在使用MVC5路由属性之前,URL为C# MVC5属性路由不工作,c#,asp.net-mvc-4,routing,asp.net-mvc-routing,url-routing,C#,Asp.net Mvc 4,Routing,Asp.net Mvc Routing,Url Routing,我正在项目中使用MVC5路由属性 我在主页上有搜索控件。当用户单击搜索按钮时,控制值将传递给搜索控制器操作 在使用MVC5路由属性之前,URL为http://localhost:5344/Search/View1?City=XYZ&Cat=ABC 家庭控制器代码: public ActionResult IndexFront(string City, string Search, string hidCategory, string btnSubmit) { retu
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,并给出错误“未找到页面”
我没有找到解决这个问题的办法
我做得对吗
请帮忙。提前谢谢。谢谢大家
找到了答案。我从主控制器传递了错误的参数名称。请尝试
返回重定向到操作(“SearchWithCityCat”、“Search”、