首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

.net MVC4登记后跳转

2013-10-18 
.net MVC4注册后跳转我想实现在http://localhost/Account/Register页面注册点击提交后,仍在当前URL下显示

.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);
                    
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }
 
            // If we got this far, something failed, redisplay form
            return View(model);
        }

[解决办法]
using 

return RedirectToAction("ConfirmationPage","Account", new {message = "Your registration will need be confirmed"})

热点排行