|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Session State Problem
Hi all,
This is my situation: I have an index page with 2 links, that send a value through query string: <a href="login/login.aspx?dsn=ARCMED">ARCMED</a> e <a href="login/login.aspx?dsn=HPD">HPDD</a> The querystring value is passed to the login page to define a global variable that will corresponde to the connection string from web.config: public myConnection As New OracleConnection(ConfigurationSettings.AppSettings(httpcontext.Current.Request.QueryString.Get("dsn") + "_" + "DSN")) and in web.config I have: <appSettings> <add key="ARCMED_DSN" value="Password=password1;User ID=user1;Data Source=datasource1;" /> <add key="HPD_DSN" value="Password=password2;User ID=user2;Data Source=datasource2;" /> </appSettings> and finally, still in login.aspx, I pass the querystring value to a session for future use in connection string definition when ever I need it: session("dsn")=httpcontext.Current.Request.QueryString.Get("dsn") The problem is that after I login... that goes well, I'm transfered to another page. In that page, when I click on any button that calls popups, that need the value stored in the session("dsn") to make the connection to an oracle db, I get this error: Server Error in '/login' Application. Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive I've tried already to set enableSessionState=true in all the popup pages that give me this error, and even in web.config as well. I've seen in forums: You are trying to use a session or use a session's properties in a class and ASP.NET cannot get a reference to a session object Resolution : Use System.Web.HttpContext.Current.Session to refer to the session instance for the current http request instead of the Session Keyword . System.Web.HttpContext.Current.Session provides you with the System.Web.HttpSessionState instance for the current HTTP request. Tried that too. I can't understand what I'm doing wrong. Is there another way to achive this? Thanks in advanced Mário Ramos |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > .Net Development > Session State Problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|