控制器没有拿起路线? [英] The controller is not picking up the route?
本文介绍了控制器没有拿起路线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有路线。
I have the routes.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("SurveySubmitRoute", "Survey/Submit",
defaults: new {action = "Submit", controller = "Survey"});
routes.MapRoute("SurveyWelcomeRoute", "Survey/{id}",
defaults: new { action = "Index", controller = "Survey" });
routes.MapRoute("SurveyLanguageRoute","Survey/Language{languageName}",
defaults: new { action = "Language", controller = "Survey" });
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }
);
}
在我看来,我想转到语言方法。
In my view, I want to go to the Language method.
window.location.href = "/Survey/Language?languageName=" + selectedValue;
在控制器中,我们有
In the controller, we have
public ActionResult Index(Guid id){ // omitted details}
和
And
public ActionResult Language(string languageName)
{
// omitted the details
}
我的问题是代码没有转到语言方法。总是去索引方法。
为什么?
我尝试过:
到目前为止还没有任何线索。感谢您的帮助。
My question is the code doesn't go to Language method. It always goes to Index method.
Why?
What I have tried:
No clue so far. Thanks for help.
推荐答案
"Survey/Language{languageName}"
window.location.href = "/Survey/Language?languageName=" + selectedValue;
两者都错了......
Both are wrong...
"Survey/Language/{languageName}"
window.location.href = "/Survey/Language/" + selectedValue;
试试这些......
Try these...
这篇关于控制器没有拿起路线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文