小编Sér*_*gio的帖子

如何在web方法中访问会话?

我可以在一个内部使用会话值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)

c# session

82
推荐指数
2
解决办法
9万
查看次数

标签 统计

c# ×1

session ×1