Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用MVC 4 don'提交表格;不要触发我在开始时指定的操作_C#_Asp.net Mvc_Asp.net Mvc 4 - Fatal编程技术网

C# 使用MVC 4 don'提交表格;不要触发我在开始时指定的操作

C# 使用MVC 4 don'提交表格;不要触发我在开始时指定的操作,c#,asp.net-mvc,asp.net-mvc-4,C#,Asp.net Mvc,Asp.net Mvc 4,我在向控制器中的特定方法提交表单时遇到问题 当用户单击我的提交按钮时,将触发索引操作,忽略在我的BeginForm中指定的我的验证登录操作 我的表格有什么问题 HTML @model Login.Models.Autenticacao @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width"

我在向控制器中的特定方法提交表单时遇到问题

当用户单击我的提交按钮时,将触发
索引
操作,忽略在我的
BeginForm
中指定的我的
验证登录
操作

我的表格有什么问题

HTML

@model Login.Models.Autenticacao
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <link href="~/Content/bootstrap.css" rel="stylesheet" />
    <link href="~/Content/endless.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.8.2.js"></script>    
</head>
    <body>
            <div id="formAutenticacao">
                <div class="pace pace-inactive">
                    <div data-progress="99" data-progress-text="100%" style="width: 100%;" class="pace-progress">
                        <div class="pace-progress-inner"></div>
                    </div>
                    <div class="pace-activity"></div>
                </div>
                <div class="login-wrapper">
                    <div class="text-center">
                        <h2 class="fadeInUp animation-delay8" style="font-weight: bold">
                            <img src="~/Images/Horizonta_com_S.png" />
                        </h2>
                    </div>
                    <div class="login-widget animation-delay1">
                        <div class="panel panel-default">
                            <div class="panel-body">
                                    @using (Html.BeginForm("ValidateLogin", "Login", FormMethod.Post))
                                    {
                                        <div class="form-group">
                                            <label>User</label>
                                            @Html.TextBoxFor(m => m.UserName, new {placeholder = "Type user name", Class = "form-control input-sm bounceIn animation-delay2"})
                                        </div>
                                        <div class="form-group">
                                            <label>Password</label>
                                            @Html.PasswordFor(m => m.Password, new {placeholder = "Type the password", Class = "form-control input-sm bounceIn animation-delay4"})
                                        </div>
                                        <div class="seperator"></div>
                                        <hr>

                                        <input type="submit" value="Go!" />
                                    }
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <iframe id="iframePrincipal" height="0" width="100%" frameborder="0"></iframe>
</body>
</html>
路线

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Login", action = "Index", id = UrlParameter.Optional }
        );
    }
型号

public class Autenticacao
{
    [Required]
    public virtual string UserName { get; set; }

    [Required]
    public virtual string Password { get; set; }
}
萤火虫

仅供参考:为了更好地理解这个问题,我翻译了我的
行动的名称

找到了我的错误

在Web.config中,我对以下行进行注释



萤火虫怎么说?请求要去哪里?您是否检查了在生成的html中表单标记上呈现的路由(使用浏览器的查看源)?@WeSt在firebug中说
重新加载页面以获取源代码:http://localhost:53059/Login/ValidateLogin
并传递了所有参数。但是我的方法ValidateLogin应该只返回一个视图。@SivaGopal@Lucas\u Santos:请添加您的最后一条评论作为答案,并在可能的时候接受它。否则,这个问题将保持“未回答”。
public class Autenticacao
{
    [Required]
    public virtual string UserName { get; set; }

    [Required]
    public virtual string Password { get; set; }
}