0
我在这里和其他地方看到很多帖子,指出可以从app_code访问会话变量。我想访问已经创建的会话。如何从APP_CODE访问一个asp.net会话变量?
由于空例外,此代码出错。 string myFile = HttpContext.Current.Session [“UploadedFile”];
这会创建一个空会话变量。 System.Web.SessionState.HttpSessionState Session = HttpContext.Current.Session;
看起来我可以创建一个新的会话变量,但不能访问已创建的会话变量。任何人都知道什么可能会给我带来麻烦?
你的代码在哪里运行? – SLaks 2010-04-11 01:10:14
它位于Web服务的app_code目录中。以下语句都返回null。命名错误的会话变量'file'是由代码中的这一点设置的。 string myfile = HttpContext.Current.Session [“file”]。ToString(); string FileName = Session [“file”]。ToString(); – user313714 2010-04-11 21:30:59