when make jquery call, authentication failed response:
{ message: "authentication failed.", stacktrace: null, exceptiontype: "system.invalidoperationexception" } jquery call:
$(document).ready(function () { //handle change event drop down list $("#ddregions").change(function () { //create ajax request $.ajax({ type: "post", //http method url: '<%= resolveurl("webform2.aspx/getlocations")%>', //page/method name data: "{}", //json represent argument contenttype: "application/json; charset=utf-8", datatype: "json", success: function (msg) { //handle callback handle response //request successful. retrieve values in response. alert(msg.tosource()); } }); }); }); the web method:
public static string getlocations() { system.diagnostics.debug.writeline("getting locations."); return "{region:auckland, city:auckland}"; } i added following web.config:
<authorization> <allow users="*" /> </authorization> <authentication mode="none" /> and tried setting autoredirectmode off in routeconfig.cs. stops error, still web method never gets called. suggestions?
resolved setting autodirectmode off in app_start/routeconfig.cs
settings.autoredirectmode = redirectmode.off; and adding scriptmanager aspx page has enablepagemethods set 'true':
<asp:scriptmanager id="scriptmanager1" runat="server" enablepagemethods="true"> </asp:scriptmanager>