【发布时间】:2010-07-23 11:14:56
【问题描述】:
这是我的应用程序当前的用户注册工作流程。
- 注册表单(GET /register)
- 提交表单(POST /register)
- 成功后,重定向路由到“/registerSuccess”
- 在 (GET /registerSuccess ) 视图中,我想显示类似“用户名已成功注册”的消息。
控制器动作:
public ActionResult Register()
{
return View();
}
[HttpPost]
public ActionResult Register(string name, string password, string confirmPassword)
{
TempData["registered_user"] = name;
return RedirectToRoute("RegisterSuccess");
}
public ActionResult RegisterSuccess()
{
return View();
}
注册成功视图
<h2><%: TempData["registered_user"] %> has been registered successfully.</h2>
除了用户刷新页面时用户名为空(GET /registerSuccess)之外一切正常。
在其他应用程序中是否正常?还是我应该对此做些什么? :) (这是我最喜欢的项目,需求来自我:P)
更新:其实还有一步就是注册用户需要管理员的批准。所以,我不能让用户在注册成功后登录。我目前正在使用基于 cookie 的 FormsAuthentication 来跟踪登录用户。
我更喜欢使用PRG 模式,而不是在提交表单中显示 Flash 消息。
【问题讨论】: