你应该写在Application_OnStart(Object sender, EventArgs e)事件中

解决方案 »

  1.   

    在Session_start中
    你还没有搞清楚Session和Application的区别
      

  2.   

    do it in Session_Start or if you need to change it,  do it afterApplication_AcquireRequestState
    see
    http://www.wintellect.com/resources/faqs/default.aspx?faq_id=1&page=2http://www.c-sharpcorner.com/asp/Articles/DetailedViewOfGlobalAsaxDPL.asp- BeginRequest
    - AuthenticateRequest
    - AuthorizeRequest
    - ResolveRequestCache
    - AcquireRequestState
    - PreRequestHandlerExecute
    - PreSendRequestHeaders
    - PreSendRequestContent
    - (actual processing)
    - PostRequestHandlerExecute
    - ReleaseRequestState
    - UpdateRequestCache
    - EndRequest
      

  3.   

    我是在"每次"请求都要处理的.
    现在暂时使用Context了.如果使用Session应该在什么地方处理?
    思归意思是在Application_AcquireRequestState中处理?
      

  4.   

    不能,这时候还没有session对象