How can I access session in a webmethod?

后端 未结 6 1591
礼貌的吻别
礼貌的吻别 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:36

    There are two ways to enable session for a Web Method:

    1. [WebMethod(enableSession:true)]
    
    2. [WebMethod(EnableSession = true)]
    

    The first one with constructor argument enableSession:true doesn't work for me. The second one with EnableSession property works.

提交回复
热议问题