0
我正在使用mvc,c#和boostrap。在我的導航欄中,我有一個下拉式登錄。它被放置爲像facebook登錄,右上角。下拉式登錄Mvc
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><img class="img-responsive" src="/images/h-perfil.png" alt="imagen"> perfil <span class="caret"></span></a> <div class="dropdown-menu" style="padding: 15px; padding-bottom: 0px;">
<form method="post" action="login" accept-charset="UTF-8">
<input style="margin-bottom: 15px;" type="text" placeholder="Email" id="username" name="username">
<input style="margin-bottom: 15px;" type="password" placeholder="Contraseña" id="password" name="password">
<input class="btn btn-primary btn-block" type="submit" id="sign-in" value="Ingresar">
<label style="text-align:center;margin-top:5px">Registrarme</label>
</form>
</div>
</li>
我想知道如何使用模型登錄用戶。我也有一個使用我的模型的控制器。這是我的控制器
public ActionResult LogIn(UserModel model)
{
if (!ModelState.IsValid) //Checks if input fields have the correct format
{
return View(model); //Returns the view with the input values so that the user doesn't have to retype again
}
if (credential valids)
{
return RedirectToAction("Index", UserModel); }
所以在這種情況下,我希望用戶在點擊按鈕時登錄。由於
你能發佈的usermodel類。基本上這些類的屬性應該匹配輸入標籤的名稱屬性。當你提交時,UserModel類將自動填充 –
嗨,謝謝你的回答。這是 –
這是模型:public class userlogin { public string Email {get;組; } public string Password {get;組; } } 所以,你說它會自動填充。但是,如何在點擊按鈕登錄時調用稱爲Login的控制器操作? 再次感謝! –