Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.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# 如何修复404';找不到资源';在asp.NETMVC中_C#_Mysql_Asp.net Mvc - Fatal编程技术网

C# 如何修复404';找不到资源';在asp.NETMVC中

C# 如何修复404';找不到资源';在asp.NETMVC中,c#,mysql,asp.net-mvc,C#,Mysql,Asp.net Mvc,我正在ASP.NET MVC中开发登录页面,我面临一个问题: Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it i

我正在ASP.NET MVC中开发登录页面,我面临一个问题:

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.
请求的URL:/Verify

我尝试了一条定制路线,但似乎无法解决问题。 这是我这里唯一的控制器

 public class HomeController : Controller
{
    // GET: Home

    MySqlConnection conn = new MySqlConnection();
    MySqlCommand cmd = new MySqlCommand();
    MySqlDataReader dr;

    [HttpGet]
    public ActionResult Index()
    {
        return View();
    }
    void connectionString()
    {
        conn.ConnectionString = "Server=localhost;Database=prodavnica;Uid=root`;Pwd=1234;Port=3306";
    }
    [HttpPost]
    public ActionResult Verify(Account acc)
    {


            connectionString();
            conn.Open();
            cmd.Connection = conn;
            cmd.CommandText = "select * from prodavnica.vraboteni where korisnik='" + acc.Username + "'and lozinka='" + acc.Password + "' ";

            if(dr.Read())
            {
                conn.Close();
                return View("Success");
            }
            else
            {
                conn.Close();
                return View();

            }

    }
}
} 路由配置:

     routes.MapRoute(

            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
这里是项目的前端,我也有一个布局,我尝试了多次,但我仍然得到相同的错误

/head>
<body>
<div class="login-form">
    <form action="Verify" method="post">
        <h2>Најави се</h2>
        <div class="form-group">
            <label>Корисник : </label>
            <input type="text" name="Username" class="form-control" required="required" />
        </div>
        <div class="form-group">
            <label>Лозинка: </label>
            <input type="password" name="Password" class="form-control" required="required" />
        </div>
        <div class="form-group clearfix">
            <button type="submit" class="btn btn-primary pull-left">
                Најави се
            </button>
            <label class="checkbox-inline pull-left remember-me"><input type="checkbox" /> Запамти ме</label>
        </div>
        <div><a href="#">Проблеми со најавувањето ? </a></div>
    </form>
</div>
/head>
Најави се
Корисник : 
Лозинка: 
Најави се
Запамти ме

它有一个post方法。

我认为您需要对表单操作执行/Verify或/Home/Verify,缺少初始斜杠


如果这不起作用,请在chrome中打开开发者工具,并在网络选项卡上确保这是一个post请求,并确保将参数正确传递给操作。如果您需要帮助,请在这里发布您看到的内容。

我认为您需要对表单操作执行/Verify或/Home/Verify,缺少初始斜杠


如果这不起作用,请在chrome中打开开发者工具,并在网络选项卡上确保这是一个post请求,并确保将参数正确传递给操作。如果您需要帮助,请在此处发布您看到的内容。

请求url应包含
http://yoursite/Home/Verify
——不仅仅是
http://yoursite/Verify
…正在使用哪个进行测试?我试图更改“url:{controller}/{action}/{id}”,以显示主页,但仍然收到相同的错误是,我正在我的浏览器中测试它。它只显示:影响测试的两个因素:1)您正在测试的控制器操作是后期操作,因此您无法使用浏览器对其进行测试(最初我忽略了这一事实)2)即使您尝试测试的控制器操作是GET,它仍然无法使用:
localhost:44334/Verify
工作,因为它必须是
localhost:44334/Home/Verify
我应该更改路由配置吗?请求的url应该有
http://yoursite/Home/Verify
——不仅仅是
http://yoursite/Verify
…正在使用哪个进行测试?我试图更改“url:{controller}/{action}/{id}”,以显示主页,但仍然收到相同的错误是的,我正在从浏览器进行测试。它只显示:影响测试的两个因素:1)您正在测试的控制器操作是后期操作,因此您无法使用浏览器对其进行测试(最初我忽略了这一事实)2)即使您尝试测试的控制器操作是GET,它仍然无法使用:
localhost:44334/Verify
,因为它必须是
localhost:44334/Home/Verify
我是否应该更改路由配置?