我使用的是放置在母版,以用戶LoginBox能夠從任何網站頁面登錄。LoginBox在母版的ASP.NET MVC
的形式作用是通過
<% using (Html.BeginForm("LogOn", "Account", FormMethod.Post))
但經過POST聲明,如果未能出現登錄我需要留在同一頁面顯示和驗證消息。
所以,我該怎麼辦留調用頁面上,而不是被重定向到帳戶登錄查看?
謝謝。
我使用的是放置在母版,以用戶LoginBox能夠從任何網站頁面登錄。LoginBox在母版的ASP.NET MVC
的形式作用是通過
<% using (Html.BeginForm("LogOn", "Account", FormMethod.Post))
但經過POST聲明,如果未能出現登錄我需要留在同一頁面顯示和驗證消息。
所以,我該怎麼辦留調用頁面上,而不是被重定向到帳戶登錄查看?
謝謝。
所以後會到你的帳戶控制,登錄動作。我建議你所說的「認證」的行動,而不是...
<% using (Html.BeginForm("Authenticate", "Account", FormMethod.Post))
這樣一來,你的行動會做authenticaion和失敗的身份驗證將返回視圖()和sucess會帶你去的loggedIn視圖。
您可以附加在你的登錄表單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"])}