Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 3-Aug-17 8:40am

1 solution

C#
"Survey/Language{languageName}"
JavaScript
window.location.href = "/Survey/Language?languageName=" + selectedValue;
Both are wrong...

C#
"Survey/Language/{languageName}"
JavaScript
window.location.href = "/Survey/Language/" + selectedValue;
Try these...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900