网站名词排名怎么做,电商网站有哪些特色,佛山外贸网站设计,汉中专业网站建设开发在一般事务处理页面#xff0c;可以轻松的得到 Request,Response对象#xff0c;从而进行相应的操作#xff0c;如下#xff1a; HttpRequest Request context.Request; HttpResponse Response context.Response; 但是要得到 Session的值就没有那么简单了。比如你要在as…在一般事务处理页面可以轻松的得到 Request,Response对象从而进行相应的操作如下 HttpRequest Request context.Request; HttpResponse Response context.Response; 但是要得到 Session的值就没有那么简单了。比如你要在ashx得到保存在Session中的登录帐号Session[userAccount] 如果你只是context.Session[userAccount]的话是会报 “未将对象引用设置到对象的实例”的异常 所以如果要想取Session中的值 需要如下所示 1、引入 命名空间 using System.Web.SessionState; 2、实现IRequiresSessionState接口具体如下 /// summary /// $codebehindclassname$ 的摘要说明 /// /summary [WebService(Namespace http://tempuri.org/)] [WebServiceBinding(ConformsTo WsiProfiles.BasicProfile1_1)] public class AddUserInfo : IHttpHandler,IRequiresSessionState //就是这样显示的实现一下不用实现什么方法 { public void ProcessRequest(HttpContext context) { //... //这样你就可以如下 操作了 if(context.Session[userAccount] ! null) { string account context.Session[userAccount].ToString(); } //...继续下面的代码 }转载于:https://www.cnblogs.com/nameisxuhui/archive/2012/05/17/2506103.html