How can I access session in a webmethod?

后端 未结 6 1583
礼貌的吻别
礼貌的吻别 2020-11-29 22:42

Can i use session values inside a WebMethod?

I\'ve tried using System.Web.Services.WebMethod(EnableSession = true) but i can\'t access Session parameter

6条回答
  •  遥遥无期
    2020-11-29 23:22

    You can use:

    HttpContext.Current.Session
    

    But it will be null unless you also specify EnableSession=true:

    [System.Web.Services.WebMethod(EnableSession = true)]
    public static String checaItem(String id)
    { 
        return "zeta";
    }
    

提交回复
热议问题