【发布时间】:2013-01-17 13:55:31
【问题描述】:
我想从同一控制器中的 [HttpGet] Action 重定向到 [HttpPost] Action。
有可能吗?
我试图不为登录重写相同的代码,因为它是一个复杂的,而不是典型的登录函数
这是我的代码:
[HttpGet]
public ActionResult Login(){
return View();
}
[HttpPost]
public ActionResult Login(LoginModel model)
{
//search user and create sesion
//...
if (registered)
{
return this.RedirectToAction("Home","Index");
}else{
return this.RedirectToAction("Home", "signIn");
}
}
[HttpGet]
public ActionResult signIn(){
return View();
}
[HttpGet]
public ActionResult signInUserModel model)
{
//Register new User
//...
if (allOk)
{
LoginModel loginModel = new LoginModel();
loginModel.User = model.User;
loginModel.password = model.password;
//next line doesn't work!!!!!
return this.RedirectToAction("Home","Login", new { model = loginModel);
}else{
//error
//...
}
}
任何帮助将不胜感激。
谢谢
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 web-applications razor web