0
所有我試圖做的是創建一個登錄控件,我想放在我的主頁。MVC部分登錄控制
香港專業教育學院創建了一個登錄用戶控制如下:
<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl(Of MyWebsite.LogOnModel)" %>
<% Using Html.BeginForm() %>
<%: Html.ValidationSummary(True, "Login was unsuccessful. Please correct the errors and try again.")%>
<div>
<div class="editor-label">
<%: Html.LabelFor(Function(m) m.UserName) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(Function(m) m.UserName) %>
<%: Html.ValidationMessageFor(Function(m) m.UserName) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(Function(m) m.Password) %>
</div>
<div class="editor-field">
<%: Html.PasswordFor(Function(m) m.Password) %>
<%: Html.ValidationMessageFor(Function(m) m.Password) %>
</div>
<div class="editor-label">
<%: Html.CheckBoxFor(Function(m) m.RememberMe) %>
<%: Html.LabelFor(Function(m) m.RememberMe) %>
</div>
<p>
<input type="submit" value="Log On" />
</p>
</div>
<% End Using %>
我比家裏的Index.aspx頁面上呈現這樣的:
Html.RenderPartial("UsrCtlLogin")
它正確地顯示了在主頁上。但我的問題是我如何將它連接到AccountController邏輯。即在點擊登錄時,我希望它激發LogOn http方法並驗證用戶(如果提供了無效詳細信息,則顯示無效消息),並且如果它們成功,則將它們重定向到頁面。
如何創建用戶控件和AccountController之間的鏈接?
在此先感謝