Asp.net mvc 4 partialview中的Submit按钮返回不带布局的结果

Asp.net mvc 4 partialview中的Submit按钮返回不带布局的结果,asp.net-mvc-4,partial-views,Asp.net Mvc 4,Partial Views,我有一个与partialView共享的布局,用于登录。 若登录过程成功,它将重定向到主页,一切正常,但若登录失败, 它只返回包含错误的局部视图,而不返回共享布局 结果是一个包含以下url的页面:localhost:35967/Account/Login,其中只有partialview包含验证摘要错误 如何修复它 这是我的密码: AccountController.cs [HttpGet] public ActionResult Login() { retu

我有一个与partialView共享的布局,用于登录。 若登录过程成功,它将重定向到主页,一切正常,但若登录失败, 它只返回包含错误的局部视图,而不返回共享布局

结果是一个包含以下url的页面:
localhost:35967/Account/Login
,其中只有partialview包含验证摘要错误

如何修复它

这是我的密码:

AccountController.cs

    [HttpGet]
    public ActionResult Login()
    {
        return PartialView();
    }

    [AllowAnonymous]
    [HttpPost]
    public ActionResult Login(LoginModel login,string returnUrl)
    {
        if (ModelState.IsValid)
        {
            if (ValidateUser(login))
            {
                FormsAuthentication.SetAuthCookie(login.Username, false);
                return Redirect(returnUrl ?? Url.Action("Index", "Home"));
            }

            ModelState.AddModelError("", "User not found");
        }

        return PartialView(login);
    }
Login.cshtml

@model DesignCrafts.MVC.Models.LoginModel
@using (Html.BeginForm("Login", "Account", FormMethod.Post, new { id = "login", @class = "enter_form" }))
{
<span style="color:red">@Html.ValidationSummary(true, "Login failed")</span>

    @Html.TextBoxFor(model => model.Username, new { @placeholder = "username" })
    @Html.ValidationMessageFor(model => model.Username)

    @Html.PasswordFor(model => model.Password, new { @placeholder = "password" })
    @Html.ValidationMessageFor(model => model.Password)

    <input type="submit" value="login" class="btn" />

    <span style="margin-right:5px">
        @Html.ActionLink("register", "Register", "Account", new { @class = "white-link"})
    </span>
    @Html.ValidationSummary(true, "user not found")

}
@model DesignCrafts.MVC.Models.LoginModel
@使用(Html.BeginForm(“Login”、“Account”、FormMethod.Post、new{id=“Login”、@class=“enter_form”}))
{
@Html.ValidationSummary(true,“登录失败”)
@Html.TextBoxFor(model=>model.Username,新的{@placeholder=“Username”})
@Html.ValidationMessageFor(model=>model.Username)
@Html.PasswordFor(model=>model.Password,新的{@placeholder=“Password”})
@Html.ValidationMessageFor(model=>model.Password)
@ActionLink(“register”、“register”、“Account”,new{@class=“white link”})
@Html.ValidationSummary(true,“未找到用户”)
}
_Layout.cshtml

     @if (Request.IsAuthenticated)
     {
        <div class="enter">
        <div>
        Logged as: @User.Identity.Name
        </div>
        @Html.ActionLink("Log out", "Logoff", "Account", null, new { @class = "exit" })
        </div>
      }
     else
      {
          { Html.RenderAction("Login", "Account"); }
      }
@if(Request.IsAuthenticated)
{
记录为:@User.Identity.Name
@ActionLink(“注销”、“注销”、“帐户”、空、新{@class=“exit”})
}
其他的
{
{Html.RenderAction(“登录”、“帐户”);}
}

只要在登录时根据该负载应用条件即可layout@Exception你能说得更具体些吗?我应该在哪里应用该条件?什么条件?你到底想要什么@Ido@Exception对不起,我不明白你的答案。我应该在哪里应用该条件?什么情况?thanks@Ido..just请告诉我你到底想要什么…请告诉我你的要求。。。