473,500 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.Net session variable

109 New Member
Hi all,

I have problem with session variable on .net web form.

I am saving ID in session to pull up the other .net web form it works fine with my development environment but as soon as I put my application in production environment but session varible doesn't work.

this what I have in session:

String getid = Session["qid"].ToString();

and my "getid" comes null in production.

It is very urgent I am suppossed to release this application and I got stuck with this problem.

Please please can anyone explian me this situation?

Thank you Thank You
Apr 3 '08 #1
9 1724
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
Technically you should be typecasting the session tot a String type;

String getid = (String)Session["qid"];

moreover if getid is being thrown at null,
then Session["qid"] should be null, and Session["qid"].ToString should throw an exception

The result you see may be IIS specific. Have you defined the session variables in global.asax ?
Apr 3 '08 #2
kunal pawar
297 Contributor
First trace ur session set properly or not
Apr 3 '08 #3
arial
109 New Member
I tried to dubugg and this is what i have found out.

My session variable get to my another form which doesn't need this session variable but I am getting null in a webform where I need this session variable.
for example this is what I have;

Expand|Select|Wrap|Line Numbers
  1. form1:
  2.  
  3. session["qid"] = qid...............this one does gets the value of qid
  4.  
  5. Form2: 
  6.  
  7. string test = Session["qid"].ToString(); ...................test does gets value of qid
  8.  
  9. form3:
  10.  
  11. string getid = Session["qid"].ToString(); ..................getid is null here.
  12.  
It is just not making any sense to me.

How would I initialize session variable in globas.aspx file?
Apr 3 '08 #4
balabaster
797 Recognized Expert Contributor
How would I initialize session variable in globas.aspx file?
I'm betting you don't have a global.asax file in your web application...

In Solution Explorer, right click your application and click Add/New Item...
Select a Global Application Class (the name will be Global.asax in the edit field at the bottom).
Click Add

In the Global.asax.cs file which comes up, in the Session_Start routine initiate your variables as such:

session["Field1"] = "";
session["Field2"] = "";
//etc.

When I've run across this problem in the past, that's usually what I've missed.
Apr 3 '08 #5
Plater
7,872 Recognized Expert Expert
I don't think i've ever declared Session variables in the global.asx page.
I suppose that would mean you don't need to check for null, just for empty strings.
A lot of people seem to be having trouble with their Session objects lately and I can't reproduce any of their problems.
Apr 3 '08 #6
balabaster
797 Recognized Expert Contributor
I don't think i've ever declared Session variables in the global.asx page.
I suppose that would mean you don't need to check for null, just for empty strings.
A lot of people seem to be having trouble with their Session objects lately and I can't reproduce any of their problems.
It's been a whlie since I used session objects, but when I had this issue in the past, that's exactly the way I've solved it.
Apr 3 '08 #7
arial
109 New Member
Thank you all for your reply.

I declare session to the global file so, now i am not getting an error message but it is not displaying the data.

need more help on to resolve this.

Thank you
Apr 3 '08 #8
kunal pawar
297 Contributor
check u allowed session for this page, coz there is property in @page to allow session. another thing check qid is empty / null
Apr 4 '08 #9
arial
109 New Member
Thanks Kunal,

I do have string qid = "";

and what property to check for allowing session at page?

Thank You
Apr 4 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

11
3320
by: doltharz | last post by:
Please Help me i'm doing something i though was to be REALLY EASY but it drives me crazy The complete code is at the end of the email (i mean newsgroup article), i always use Option...
1
3093
by: Ann Leland | last post by:
I have been using session variables to pass a user name from one ASP page to another inside framesets for 9 months and it stopped working this week. I have made no code changes but there was a...
2
13508
by: Eric | last post by:
Hi, I've a problem with trying to retrieve a session variable in an include file. Basically, the main asp creates a session variable: <% Session("var1") = "Hello" %> And then when I click...
4
1635
by: VB Programmer | last post by:
If I have a variable I want to share in my application what is the difference between just declaring a variable (Dim strMyVar as String) and using a session variable (Session("strMyVar"))? When...
9
2437
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
9
2363
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
4
1939
by: T Ralya | last post by:
I am told that ASP.NET controls the session ID and session variables, but that does not fit my symptoms. I am posting here as directed. I'm hoping that someone can at least recommend something to...
3
2888
by: Alan Wang | last post by:
Hi there, Once my application gets complicated and complicated. I found it's really hard to keep track of Session value I am using in my asp.net application. I am just wondering if anyone have...
4
3426
by: Don Miller | last post by:
I am using a Session variable to hold a class object between ASP.NET pages (in VB). In my constructor I check to see if the Session variable exists, and if it doesn't, I create one and populate it...
17
5062
by: Control Freq | last post by:
Hi, Not sure if this is the right NG for this, but, is there a convention for the variable names of a Session variable? I am using .NET 2.0 in C#. I am new to all this .NET stuff, So, any...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.