[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Access session in Application_AuthenticateRequest

Posted on 2006-07-19
7
Medium Priority
?
2,284 Views
Last Modified: 2008-01-09
i want to access session object in Application_AuthenticateRequest when i tries to it returns null

. how to do ?

or other wise is there any global place for the wole application to access the session object every time the user goes to a new page
0
Comment
Question by:hema3i
  • 2
4 Comments
 
LVL 7

Expert Comment

by:skvikram
ID: 17140787
YES in web.config saved in root directory of application

<configuration>
  <system.web>
    <sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" />
  </system.web>
</configuration>

OR

<configuration>
  <system.web>
    <sessionState
       mode="SQLServer"
       sqlConnectionString="Server=127.0.0.1;UID=sa;PWD=secret" />
  </system.web>
</configuration>
0
 
LVL 3

Accepted Solution

by:
alecpotts earned 200 total points
ID: 17242536
The session object is the "per user" state object; while the Application_AuthenticateRequest is a mehtod that fires at the application level, rather than at the session level. If you try to access the session object here, I don't believe ASP .NET will have any way of knowing which user you are working with, and hence session returns null.

Try using the application state object; this is global to the application. So...

Application["MyStuff"] instead of  Session["MyStuff"]

Regards
0
 
LVL 3

Expert Comment

by:alecpotts
ID: 17388341
Hi,

I believe my answer is technically accurate - of course I don't know if it helped or not...!

IMO the answer from skvikram describes how to set up your session state in different ways, but not how to access it.

The last (and to a lesser extent, the first) link provided by pradeepsudharsan describe a similar problem, so could have been useful also.

Alec
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month18 days, 12 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question