Solved

Access session in Application_AuthenticateRequest

Posted on 2006-07-19
7
2,146 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
7 Comments
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 17136856
0
 
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 50 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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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