0

I am using ASP.NET MVC 3 and following the tutorial here http://www.asp.net/mvc/tutorials/asp-net-mvc-routing-overview-cs.

I am working on the sign up functionality and trying to make use of routing. So the typical scenario is:

  1. When the user wants to sign up, he would get taken to /Account/SignUp.
  2. Upon succesful sign up, he then gets redirected to /Account/SignUp/Successful.

I thought it would be simple enough but the "Successful" parameter never gets passed in the SignUp method in the controller.

 public ActionResult SignUp(string msg)
 {
     // Do some checks on whether msg is empty or not and then redirect to appropriate view
 }

In global.aspx.cs I've got pretty much the vanilla routing:

   routes.MapRoute(
            "Default",
            "{controller}/{action}/{id}",
            new { controller = "Home", action = "Index", id = UrlParameter.Optional });

What am I failing to grasp here?

2 Answers 2

1

Your route parameter is called id, so:

public ActionResult SignUp(string id)
{
    ...
}

or change it to msg if you want:

"{controller}/{action}/{msg}"
Sign up to request clarification or add additional context in comments.

Comments

0

Change the parameter from your method to id and create an get method for the /Account/SignUp action

public ActionResult SignUp()
{
  //this is the initial SignUp method
}

[HttpPost]
public ActionResult SignUp(string id)
{
  //User will be redirected to this method
}

1 Comment

Hey Andrew, isn't the second method all that's required?

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.