calling webmethod from jquery C# returning 404 error in .net aspx page -
must missing basic here. getting 404 error calling webmethod jquery in aspx page i'm running locally.
<%@ page language="c#" autoeventwireup="true" codebehind="empjquery.aspx.cs" inherits="webapioracle.empjquery" %> <!doctype html> <html lang="en"> <head runat="server"> <title>jquery emps</title> <script src="scripts/jquery-1.10.2.min.js"></script> <link href="../content/bootstrap.min.css" rel="stylesheet" /> <script type="text/javascript"> $(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!!! "); } }); } </script>
then in code behind page
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"; } } }
i'm getting 404 error whenever run attempted changing url /empjquery.aspx/test tried localhost/empjquery.aspx/test , localhost:48784/empjquery.aspx/test can't seem it. need add web config? i'm running .net 4.5 thanks
ok, found app hybrid mvc
, web api
, aspx
solution , route configs messing me had add:
routes.ignoreroute("{page}.aspx/{*webmethod}");
Comments
Post a Comment