日期:2014-05-17  浏览次数:20406 次

.net MVC4注册后跳转
我想实现在http://localhost/Account/Register页面注册点击提交后,仍在当前URL下显示注册结果信息,是否可行?
就像小米的,在https://account.xiaomi.com/pass/register注册,点击注册后在当前URL下显示One last step, please activate your account 

An activation mail has been sent to your email

Please check your email fdasfda@qq.com,click on the link in the email to activate your account

------解决方案--------------------
当然可行。

直接跳转到当前页,设置TempData为注册成功的信息,并且在控制器中判断下。
------解决方案--------------------

[HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.Email, model.Password, new
                    {
                        UserName = model.UserName, 
                        Question = model.Question,
                        Answer   = model.Answer,
                        Telphone = model.Telphone 
                    });
                   // WebSecurity.Login(model.Email, model.Password);
                  //  return RedirectToAction("Index", "Home");
                     
                    return View("这里写你另一个视图名称,该视图显示注册成功后的内容",model);
   &nbs