asp.net ajax 401,ASP.NET使用jQuery AJAX调用WebMethod"401(未经授权)"

被困这几个小时了

{"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}

我试图在我的ASP.Net Webform中调用这个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();

}

从这个jquery.ajax

function 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);

}

});

}

但我总是得到这个错误:

POST http://localhost:64365/ConsultaPedidos.aspx/GetClients 401(未经授权)

奇怪的是,这开始工作直到我开始验证用户

...

...

有任何想法吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值