WebMethod not called when url rewrite active
ajax, c#, jquery, webmethod
Solution
You'll need to use an complete link to your web method.
If you look in firebug you'll see, for example:
http://localhost/test1/index.aspx/SaveSetting as the url that you're trying to request, assuming that /test1 rewrites to /index.aspx
Assuming that the page lives at the root of your site, the following will work:
url: /index.aspx/SaveSetting
(This doesn't work at all with url routing, by the way!)
Perhaps move your web methods into an asmx file instead?
Problem
I know there are simular posts out there, but I found no help in any of them. My web methods work when im not using url rewriting, but as soon as I turn it on it stop working. jQuery ``` $.ajax({ type: "POST", url: "index.aspx/SaveSetting", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { console.log(msg); } }); ``` C# ``` [WebMethod()] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] public static string SaveSetting() { return "OK"; } ``` When this is called, I get the full HTML of my page back, and no "OK" message. I ran the debugger and saw that when I call the web method it triggers Page_Load in my page and not the web method. So I got the corerct path, but the web method is not called. I use C#, jQuery, ASP.NET 3.5. Any help?