2

Hi I am using this two lines in my code:

using (Ajax.BeginForm("Login", "Users", new { command = "Login"}, new AjaxOptions() { UpdateTargetId = "divLoginPopupContent" }, new { id = "loginPopup" }))
{
    /// some html with submit button

    // and also have following:
    <%= Html.ActionLink("Forgot your password", "Login", "Users", new { command = "ForgotPassword" }, null)%>
}

and this is the map route i have

routes.MapRoute(
                "Users",
                "Users/{command}",
                new { controller = "Users", action = "Login" }
            );

and this is the controller action:

public ActionResult Login(LoginModel model, string command)
     {
          /// some actions
     }

but I don'y what I am doing wrong here ... I want ActionLink and BeginForm both to be routed to this controller action.

3
  • Hm.. what kind of error are you facing? I just used snippets of your code and everything looks good.. using actionlink and submit button i'm correctly routed to login action with appropriate commands... Commented May 20, 2011 at 12:07
  • as i have model in my parameter so it not taking me to that action ... Commented May 20, 2011 at 12:11
  • and give me this error HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Commented May 20, 2011 at 12:14

1 Answer 1

2

answering my own question:

i haven't define another route collection variable i.e. command should be declared, like this

routes.MapRoute(
                "Users",
                "Users/{command}",
                new { controller = "Users", action = "Login", 
                command = Parameter.Optional }
            );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.