堅(jiān)持了幾個(gè)小時(shí){"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}我試圖在我的ASP.Net Webform中調(diào)用此WebMethod[WebMethod]public static string GetClients(string searchTerm, int pageIndex){ string query = "[GetClients_Pager]"; SqlCommand cmd = new SqlCommand(query); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SearchTerm", searchTerm); cmd.Parameters.AddWithValue("@PageIndex", pageIndex); cmd.Parameters.AddWithValue("@PageSize", PageSize); cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4).Direction = ParameterDirection.Output; return GetData(cmd, pageIndex).GetXml();}從這個(gè)jquery.ajaxfunction GetClients(pageIndex) { $.ajax({ type: "POST", url: "ConsultaPedidos.aspx/GetClients", data: '{searchTerm: "' + SearchTerm() + '", pageIndex: ' + pageIndex + '}', contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess, failure: function (response) { alert(response.d); }, error: function (response) { alert(response.d); } });}但是我總是會(huì)收到這個(gè)錯(cuò)誤:POST http://localhost:64365/ConsultaPedidos.aspx/GetClients 401(未經(jīng)授權(quán))奇怪的是,在我開(kāi)始對(duì)用戶進(jìn)行身份驗(yàn)證之前,這種方法一直有效<system.web>... <authentication mode="Forms"> <forms loginUrl="~/Account/Login" timeout="2880" defaultUrl="/Dashboard" /> </authentication> <authorization> <deny users="?" /> </authorization>...</system.web>有任何想法嗎?
使用jQuery AJAX“ 401(未經(jīng)授權(quán))”的ASP.NET調(diào)用WebMethod
呼啦一陣風(fēng)
2019-10-18 09:56:44