我可以在一个内部使用会话值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";
}
Run Code Online (Sandbox Code Playgroud)
这是调用web方法的JS:
$.ajax({
type: "POST",
url: 'Catalogo.aspx/checaItem',
data: "{ id : 'teste' }",
contentType: 'application/json; charset=utf-8',
success: function (data) {
alert(data);
}
});
Run Code Online (Sandbox Code Playgroud)