On the general transaction processing page, if you want to obtain the session value, an exception "the object reference is not set to the instance of the object" is reported.
Therefore, if you want to obtain the value in the session, you need
1. Introduce the namespace:
Using system. Web. sessionstate;
2. Implement the irequiressessionstate interface as follows:
/// Summary description of <summary> /// $ codebehindclassname $ /// </Summary> [WebService (namespace = "http://tempuri.org/")] [webservicebinding (conformsto = wsiprofiles. basicprofile1_1)] public class adduserinfo: ihttphandler, irequiressessionstate // This is the implementation of the display. No implementation method is required. {public void processrequest (httpcontext context) {// you can perform the following operations: If (context. session ["useraccount"]! = NULL) {string account = context. session ["useraccount"]. tostring () ;}//... continue the following code }}
Obtain the session on the ashx page