ASP.NET MVC 3 basic routing question
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:
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?
Your route parameter is called id
, so:
public ActionResult SignUp(string id)
{
...
}
or change it to msg
if you want:
"{controller}/{action}/{msg}"
将方法中的参数更改为id
并为/ Account / SignUp操作创建get方法
public ActionResult SignUp()
{
//this is the initial SignUp method
}
[HttpPost]
public ActionResult SignUp(string id)
{
//User will be redirected to this method
}
链接地址: http://www.djcxy.com/p/57848.html
上一篇: 在ASP.NET MVC 3 Razor中使用Ajax.BeginForm
下一篇: ASP.NET MVC 3基本路由问题