Asp.net mvc 在MVC中未命中控制器

Asp.net mvc 在MVC中未命中控制器,asp.net-mvc,Asp.net Mvc,在我提交的我的登录表单中,虽然我在beginform with post方法中提供了代码,但它并没有击中控制器。我需要将用户名和密码发送给我的控制器进行验证。无法理解为什么它没有击中 [HttpPost] public ActionResult LoginUser(UserInfo objUser) { int res = udaObj.CheckUser(objUser.UserName, objUser.Password); if (res

在我提交的我的登录表单中,虽然我在beginform with post方法中提供了代码,但它并没有击中控制器。我需要将用户名和密码发送给我的控制器进行验证。无法理解为什么它没有击中

[HttpPost]
    public ActionResult LoginUser(UserInfo objUser)
    {

        int res = udaObj.CheckUser(objUser.UserName, objUser.Password);
        if (res >= 1)
        {
           return RedirectToAction("Appointment", "Home");
        }           
        else
        {
            //For testing purpose
            return RedirectToAction("Appointment", "Home");
        }
    }
我的看法如下:

 @using (Html.BeginForm("LoginUser", "Home", FormMethod.Post, new { id = "loginForm" }))
                {
                    <div class="tab-pane fade active in" id="signin">
                        <fieldset>
                            <!-- Sign In Form -->
                            <!-- Text input-->
                            <div class="control-group">
                                <label class="control-label" for="userid">Alias:</label>
                                <div class="controls">
                                   @* <input required="" id="userid" name="userid" type="text" class="form-control" placeholder="JoeSixpack" class="input-medium" required="">*@
                                     @Html.TextBoxFor(x => x.UserName, new { @class = "form-control input-large", @placeholder = "Joek@irawath.com", @required = "" , @id="userid" })
                                </div>
                            </div>

                            <!-- Password input-->
                            <div class="control-group">
                                <label class="control-label" for="passwordinput">Password:</label>
                                <div class="controls">
                                    @*<input required="" id="passwordinput" name="passwordinput" class="form-control" type="password" placeholder="********" class="input-medium">*@
                                     @Html.TextBoxFor(x => x.Password, new { @class = "form-control input-large", @placeholder = "********", @required = "", @type = "password" , @id="passwordinput" })
                                </div>
                            </div>

                            <!-- Multiple Checkboxes (inline) -->
                            <div class="control-group">
                                <label class="control-label" for="rememberme"></label>
                                <div class="controls">
                                    <label class="checkbox inline" for="rememberme-0">
                                        <input type="checkbox" name="rememberme" id="rememberme-0" value="Remember me" style="margin-left: 0px">
                                        Remember me
                                    </label>
                                </div>
                            </div>
                            <button id="btnsignin" type="submit" name="signin" class="btn btn-success">Sign In</button>
                            <!-- Button -->
                            <div class="control-group">
                                <label class="control-label" for="signin"></label>
                                <div class="controls">
                                    @* <button id="btnsignin" type="submit" name="signin" class="btn btn-success">Sign In</button>*@
                                </div>
                            </div>
                        </fieldset>
                    </div>
                }
@使用(Html.BeginForm(“logiuser”,“Home”,FormMethod.Post,new{id=“loginForm”}))
{
别名:
@* *@
@TextBoxFor(x=>x.UserName,新的{@class=“form control input large”,@placeholder=”Joek@irawath.com“,@required=”,@id=“userid”})
密码:
@**@
@Html.TextBoxFor(x=>x.Password,新的{@class=”表单控制输入大“,@placeholder=“*******”,@required=“,@type=”密码“,@id=”密码输入“})
记得我吗
登录
@*登录*@
}

检查对象UserInfo是否与视图中使用的模型相同。尝试改用FormCollection并选中。

您的提交按钮已被注释。如何提交表单?除了默认路由之外还有其他路由吗?对不起,在已注释的块上方,您可以看到另一个未注释的按钮。使用相同的注释id。我没有提供任何其他路线。@Richard,上面提到的那个部门我又使用了一个表单进行注册。它会干扰吗?