2009-10-14 49 views
1

我使用的是放置在母版,以用户LoginBox能够从任何网站页面登录。LoginBox在母版的ASP.NET MVC

的形式作用是通过

<% using (Html.BeginForm("LogOn", "Account", FormMethod.Post)) 

但经过POST声明,如果未能出现登录我需要留在同一页面显示和验证消息。

所以,我该怎么办留调用页面上,而不是被重定向到帐户登录查看?

谢谢。

回答

0

所以后会到你的帐户控制,登录动作。我建议你所说的“认证”的行动,而不是...

<% using (Html.BeginForm("Authenticate", "Account", FormMethod.Post)) 

这样一来,你的行动会做authenticaion和失败的身份验证将返回视图()和sucess会带你去的loggedIn视图。

0

您可以附加在你的登录表单RETURNURL领域:

using (Html.BeginForm("LogOn", "Account", FormMethod.Post, new { @returnurl=Request.Uri.AbsolutePath })) 

,并在您Account.LogOn行动重定向回

ActionResult LogOn(Form form) { ... check login/password ... return Redirect(form["returnurl"])}