从jquery C#调用webmethod在.net aspx页面中返回404错误

我必须遗漏一些基本的东西。 我在本地运行的aspx页面中从jquery调用webmethod时遇到404错误。

    jquery emps    $(document).ready(function () { getEmployees(); }); function getEmployees() { jQuery.ajax({ url: 'empJquery.aspx/Test', type: "POST", contentType: "application/json; charset=utf-8", dataType: "json", beforeSend: function () { alert("Start!!! "); }, success: function (data) { alert("a"); }, error: function (msg) { alert("Sorry!!! "); } }); }  

然后在代码页面后面

 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using webApiOracle.Models; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace webApiOracle { public partial class empJquery : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } [System.Web.Services.WebMethod] public static string Test() { return "Success"; } } } 

每次运行时我都会收到404错误我试图将url更改为/empJquery.aspx/Test我也试过localhost / empJQuery.aspx / Test和localhost:48784 / empJquery.aspx / Test但我似乎无法得到它。 我需要在Web配置中添加一些内容吗? 我正在运行.net 4.5谢谢

好吧,我刚刚发现我的应用程序是一个混合的MVCWeb APIASPX解决方案,我的路由配置搞砸了我所以我不得不添加:

  routes.IgnoreRoute("{page}.aspx/{*webmethod}");