473,508 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.Net loss of session variables

8 New Member
Hi,

I am facing a problem of loss of session variables once the ASP.Net 2.0 application is deployed. Let me add that this is actually a 1.1 to 2.0 migration.

I found that the first time the page is posted, I found that session variables are getting lost. When I hit Back on IE, and re-enter, the session variables exist and things move smoothly. This problem was not occurring when I tested on my machine, but only after deployment to the server.

I have found that this is because of SSL; on removal of SSL, the session values are retained. But as the application has to be hosted as a secure website, this solution is not acceptable.

So, I tried out a few things, but haven't found any success yet:
1. I commented the existing code of
Response.Cookies ["ASP.NET_SessionID"].Secure = true;
in the global.asax.cs file
2. I tried out the suggestion on http://support.microsoft.com/kb/917412 :


Expand|Select|Wrap|Line Numbers
  1. void Session_Start(object sender, EventArgs e)
  2.         {
  3.             if (Response.Cookies.Count > 0)
  4.             {
  5.                 foreach (string s in Response.Cookies.AllKeys)
  6.                 {
  7.                     if (s == System.Web.Security.FormsAuthentication.FormsCookieName || s.ToLower() == "asp.net_sessionid")
  8.                     {
  9.                         Response.Cookies[s].HttpOnly = false;
  10.                     }
  11.                 }
  12.             }
  13.         }
3. I also tried setting to privacy setting to Low on the internet options as well as checking the Allow Session cookies option.

Is there anything that I am missing? I have spent a lot of time on this...any suggestions?
Mar 21 '07 #1
4 2806
kenobewan
4,871 Recognized Expert Specialist
Welcome to the site. Did you see this article:
SSL Termination and ASP.NET

Especially the bit about having to set the secure attribute on the FormsAuthentication cookie:
Expand|Select|Wrap|Line Numbers
  1. Response.Cookies[s].Secure = true;
Mar 21 '07 #3
leena13
8 New Member
Thanks kenobewan and Sani723 for your posts.

We are actually using Windows Authentication, not forms authentication.

I'll try to make the picture clearer by adding a few things to my earlier post:
Any authenticated user gets to see the login page, others are re-directed to an error page. When this authenticated user clicks on this page, an error occurs which is because of loss of session variables. Click back on ie, and re-post, the user can then enter the application.

On the IIS, I'm selecting SSL. In fact,
the code
Expand|Select|Wrap|Line Numbers
  1. Response.Cookies[s].secure = true 
is redundant.
Mar 21 '07 #4
Plater
7,872 Recognized Expert Expert
You are remembering that when you deploy an application all session states and varriables are lost becaise it deploys as "shutdown" and won't "startup" until a call is made to it. So if you are sitting on this "i am windowsauthenticated so i can see the login page" and then you re-deploy your project (or for whatever reason it is shut down already, possibly do to idle time) then your session state will be gone and the server has no knowledge that you are authenticated so when you click, your credentials aren't there. And it will error out.

Not sure if thats your problem, but a lot of people's questions here are because they simply were not aware that the session values get wiped out when deploying.
Jun 4 '07 #5

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

Similar topics

1
2840
by: db_guy | last post by:
Hi, we have a php-based application that is hosted by Yahoo! Webhosting. Ever since the application was created, it has been plagued by periodic session data loss. Here's a typical example: We...
17
5591
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm...
2
2577
by: Steve Remer | last post by:
OK, I think I understand session state pretty well. I've done additional research on Google over the last few days to fill in any holes. To begin with, I'm using StateServer and not InProc for...
1
3160
by: Steve Remer | last post by:
My application (relevant code snippets below) originally used Session variables in order to maintain state from page to page. After being unable to solve the mystery of why those variables were...
14
2040
by: Michael Carr | last post by:
I have an intermittent problem that occurs on a very small number of browsers that access my website. The strange thing is this: my site works perfectly for 99.9% of browsers. The behavior...
4
2746
by: Chris | last post by:
When a request comes into a page on my ASP.net site and a session is not found, I want to detect whether the request is an initial request or if the user did have a session going that has now been...
8
1674
by: Tim W. | last post by:
Chaps. We are working with SQL-Server based Sessions in the following environemtn: Win-Server 2K3 incl. IIS, Dot Net Framework 1.1, SQL2K SP3a, German. We are defining a Session-Variable...
2
1523
by: Joey | last post by:
Does anyone know why I lose all of my session variables whenever I delete files on the server using code in my asp.net web app? I have seen a few scattered posts about something called a...
0
840
by: neeraj | last post by:
Hi Every body I have one problem with my asp.net application framework 2.0 When I delete the folder from server, used all session variables and static variables loss own contained value. I...
0
7224
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
7323
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,...
1
7038
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
7493
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
5625
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
5049
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...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.