RedirectToAction(returnUrl)前置“/ Account” returnUrl [英] RedirectToAction(returnUrl) is prepending "/Account" to returnUrl

查看:96
本文介绍了RedirectToAction(returnUrl)前置“/ Account” returnUrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这刚开始时根本没有修改我的账户控制器。


 // 
// POST:/帐户/登录

[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult登录(LoginModel模型,字符串returnUrl)
{
if(ModelState.IsValid&& WebSecurity.Login(model.UserName,model.Password,persistCookie:model.RememberMe))
{
return RedirectToAction(returnUrl );
}

//如果我们到目前为止,出现故障,重新显示格式
ModelState.AddModelError("","提供的用户名或密码不正确。 ");
return View(model);
}


查看returnUrl中包含的值我得到了正确的URL,但我的浏览器被错误地路由到"/ Account" + returnUrl。

如果有人能解释为什么我找不到MVC或甚至ASP.Net论坛发布这个问题我会非常感激。




Dorian Klingenberg

解决方案

你的路线就在那里 - ---->  http://forums.asp.net/1146.aspx/1?MVC

This just started happening with no modification to my Account Controller at all.

        //
        // POST: /Account/Login

        [HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                return RedirectToAction(returnUrl);
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }

Looking at the value contained in returnUrl I get the correct URL, but my browser is incorrectly routed to "/Account" + returnUrl.

Also if someone could explain why I can't find an MVC or Even ASP.Net forum to post this question to I would very much appreciate it.


Dorian Klingenberg

解决方案

Your route is that away ----->  http://forums.asp.net/1146.aspx/1?MVC


这篇关于RedirectToAction(returnUrl)前置“/ Account” returnUrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆