我能在WebMethod
中使用会话值吗?
我尝试过使用System.Web.Services.WebMethod(EnableSession = true)
,但我无法像这个例子中的那样访问Session参数:
[System.Web.Services.WebMethod(EnableSession = true)]
[System.Web.Script.Services.ScriptMethod()]
public static String checaItem(String id)
{
return "zeta";
}
这里是调用Web方法的JavaScript代码:
$.ajax({
type: "POST",
url: 'Catalogo.aspx/checaItem',
data: "{ id : 'teste' }",
contentType: 'application/json; charset=utf-8',
success: function (data) {
alert(data);
}
});