.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 17th, 2004, 12:51 PM
mjpr mjpr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Portugal
Posts: 10 mjpr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to mjpr
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > Session State Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT