当前位置:首页 > 网络编程 > WEB编程 > ASP.net >  在asp.net中使用session常见问题集锦 2

 在asp.net中使用session常见问题集锦 2

点击次数:25 次 发布日期:2008-11-26 10:45:31 作者:源代码网
源代码网推荐      面?
源代码网推荐  答:Session_End是一个在服务器内部激发的事件处理函数。它是基于一个服务器内部的计时器的,在激发该事件时服务器上并没有相关的HttpRequest对象,因此此时并不能使用Response.Redirect和Server.Transfer方法。
源代码网推荐  
源代码网推荐  问:在Session_End中是否可以获得HttpContext对象?
源代码网推荐  答:不行,因为这个事件并没有和任何的请求(Request)相关联,没有基于请求的上下文。
源代码网推荐  
源代码网推荐  问:在Web Service中该如何使用Session?
源代码网推荐  答:为了在Web Service中使用Session,需要在Web Service的调用方做一些额外的工作,必须保存和存储调用Web Service时使用的Cookie。详细信息请参考MSDN文档的HttpWebClientProtocol.CookieContainer属性。然而,如果你使用代理服务器访问Web Service由于框架的限制,两者不能共享Session。
源代码网推荐  
源代码网推荐  问:在自定义自己的HttpHandler的时候,为什么不能使用Session?
源代码网推荐  答:在实现自己的HttpHandler的时候,如果希望使用Session必须实现下面的两个标记接口中的一个:IRequiresSessionState和IReadOnlySessionState,这些接口没有任何方法需要实现,只是一个标记接口和使用INamingContainer接口的方法一样。
源代码网推荐  
源代码网推荐  问:当我使用webfarm时,当我重定向到其他的Web服务器时Session为什么会丢失?
源代码网推荐  答:详细信息请参考:
源代码网推荐   PRB: Session State Is Lost in Web Farm If You Use SqlServer or StateServer Session Mode
源代码网推荐   http://support.microsoft.com/default.aspx?scid=kb;en-us;325056
源代码网推荐  
源代码网推荐  问:为什么我的Session在Application_OnAcquireRequestState方法中无效?
源代码网推荐  答:Session只有在HttpApplication.AcquireRequestState事件调用以后才会有效。
源代码网推荐   详细信息请参考:
源代码网推荐   http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconhandlingpublicevents.asp
源代码网推荐  
源代码网推荐  问:如果使用了cookieless,我该如何从HTTP页面定向到HTTPS?
源代码网推荐  答:请尝试下面的方法:
源代码网推荐   String originalUrl = "/fxtest3/sub/foo2.aspx";
源代码网推荐   String modifiedUrl = "https://localhost" + Response.ApplyAppPathModifier(originalUrl);
源代码网推荐   Response.Redirect(modifiedUrl);
源代码网推荐  
源代码网推荐  问:Session在global.asax中的那些事件中有效?
源代码网推荐  答:Session只有在AcquireRequestState事件之后有效,该事件之后的事件都可以使用Session。
源代码网推荐  
源代码网推荐  
源代码网推荐  问:如何获得当前Session中保存的所有对象?
源代码网推荐  答:可以通过遍历所有的Session.Keys来获得。代码如下:
源代码网推荐  ArrayList sessionCollection = new ArrayList();
源代码网推荐  foreach (string strKey in Session.Keys){
源代码网推荐   sessio
源代码网推荐  
源代码网推荐  
源代码网推荐    做人要厚道,请注明转自酷网动力(www.ASPCOOL.COM)。
源代码网推荐


源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华