By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,742 Members | 2,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,742 IT Pros & Developers. It's quick & easy.

Lose session variables in a projet but not in other one...

P: n/a
Hi,

Well, my problem is so simple as it says in the subjet but very frustrating
also. I have a project and it is losing the session variables with each
postback, so I downloaded from the web a project which used a session
management dll to discover what was wrong in my project. This web project has
two pages, one send to the other a variable with session state and the other
changes this one, shown in a label, with each postback, well, quite simple.
Ok,it runs right and the use I do with my project is similar. In fact I added
the dll of this project into my project and the two pages, to start the
project with them but it didn't kept the value of the session variables.

So... (I hope you understand me, I don't know if I explained fine) what
problem do you think I have? Maybe it's a problem related with the IIS? Any
kind of configuration for the project in Visual Studio? I've spent too much
time trying to resolve this problem but I just can't know in any way what's
the matter.

Thanks a lot in advance.
Jan 18 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Session variables can be lost due to the following reasons:

1. Session timeout has reached.
2. The AppDomain that was running your ASP.Net app has been torn down
and a new AppDomain was created (Happens when the probject is rebuilt,
or the dlls in the bin / App_Bin (2.0) directory have been replaced)
3. IIS is restarted.

Assuming its not 2/3 the most likely problem is that the session
timeout is the reason. Try tweaking the session timeout of your project
in the web.config file:

<configuration>
<system.web>
<sessionState timeout="5"/> <!-- Sets the timeout to five minutes
-->
</system.web>
</configuration>

And then retry your app. If the session variables are still being lost,
Id trace your application and see if any code is being executed while
transferring execution to the second page that resets / removes the
session variables.

If both of them do not solve the problem, the timeout problem might be
in IIS. Open IIS Manager, navigate to your virtual directory, right
click and select properties. In the Virtual Directory tab, click the
configuration button. Select App Options, there should be Session
Timeout option under Enable Session State. Set this value to 5 (in
minutes). To be sure restart IIS, and check your app again.

If all these do not work, then it has nothing to do with IIS or session
timeout and most likely the session variables are either being affected
by code, or the AppDomain is being reset for some reason.

Hope this helps...

- NuTcAsE

Jan 18 '06 #2

P: n/a
Hi NuTcAsE,

First, thanks for your effort replying to my problem. In the IIS is not the
problem as the session state is enabled and the timeout is up to 20 minutes.
Maybe the problem is in the web.config, but I'm not too sure... Let's see,
the first page is in the application folder where it's placed the web.config
too. This web.config has the sessionState up to 20 minutes. But -and here is
where I think there could be a problem- the default.aspx, the login,
transfers to a second page located in a subfolder. This second page receives
the session variable right, but on postback is lost. And in this folder
there's another web.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</configuration>

That's all. I tryied to write here the tag <sessionState timeout="5"/>, but
I can't do it, asp.net throws an error when arriving here ("t's incorrect to
use a registered section as allowDefinition='MachineToApplication' more over
the application level").

So as I'm quite newbie, I don't know what's wrong here. In any case thanks
again for your answer, I'll keep on trying. If I discover something I'll post
it, of course! :)

Greets,
Tomás.

"NuTcAsE" wrote:
Session variables can be lost due to the following reasons:

1. Session timeout has reached.
2. The AppDomain that was running your ASP.Net app has been torn down
and a new AppDomain was created (Happens when the probject is rebuilt,
or the dlls in the bin / App_Bin (2.0) directory have been replaced)
3. IIS is restarted.

Assuming its not 2/3 the most likely problem is that the session
timeout is the reason. Try tweaking the session timeout of your project
in the web.config file:

<configuration>
<system.web>
<sessionState timeout="5"/> <!-- Sets the timeout to five minutes
-->
</system.web>
</configuration>

And then retry your app. If the session variables are still being lost,
Id trace your application and see if any code is being executed while
transferring execution to the second page that resets / removes the
session variables.

If both of them do not solve the problem, the timeout problem might be
in IIS. Open IIS Manager, navigate to your virtual directory, right
click and select properties. In the Virtual Directory tab, click the
configuration button. Select App Options, there should be Session
Timeout option under Enable Session State. Set this value to 5 (in
minutes). To be sure restart IIS, and check your app again.

If all these do not work, then it has nothing to do with IIS or session
timeout and most likely the session variables are either being affected
by code, or the AppDomain is being reset for some reason.

Hope this helps...

- NuTcAsE

Jan 18 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.