ASP.NET - Loosing Session Variables

P

Patrick

Hello

I'm running two Webservers Using ASP.NET. both are running the same ASP.NET
Application, with

<sessionState mode="SQLServer" stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=myserver;user id=myuser;password=mypw"
cookieless="false" timeout="20" />

This seems to work. But we have cases, when users report that they loose the
session. I really can't say why it is lost. But I also see when that i get
sometimes errors that session-object gets empty, when it should nearly be
impossible to be empty, so I really can't figure it out.

Question,
- IIS6 Recycle doesn't matter in that case, because the Session is in SQL
Server
- Changeing the web.config doesnt effect anything of that, right?
- I checked out in the tmpdb the ASPStateTempSessions and found out, that it
is kind of 2 Hours back of the real server time, is it using GMT?
- in the ASPStateTempApplications i have just one application, is that
correct?
- Has someone some ideas?

Thanks
Patrick
 
K

Kevin Spencer

This seems to work. But we have cases, when users report that they loose
the
session. I really can't say why it is lost. But I also see when that i get
sometimes errors that session-object gets empty, when it should nearly be
impossible to be empty, so I really can't figure it out.

Perhaps they timed out?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
P

Patrick

timed out? you mean the 20minutes? - i don't think so, because the 20
minutes are always updated sinde the last click i made on the webpage,
right? or are they only valid from start of the session when using SQLServer
to store it? if yes, so this is probably the problem!
 
K

Kevin Spencer

Sessions only time out after a period of no requests from the client. So, if
your "last click" was a hyperlink or other element that caused a request to
occur, the Session isn't timing out.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
P

Patrick

Thanks Kevin, so this can't be the problem, but for beeing sure I will add a
entry to the session, when it was created, so I see the time difference
between the session started and the error..

but it really looks like the session is lost. what else can cause this when
session is on sql server?

thanks
 
K

Kevin Spencer

Not sure, Patrick. According to the .Net SDK, if you are using SQL Server,
you have a choice of 2 scripts to run to install Session State on the SQL
Server. If you use InstallSqlState.sql, a reboot of the SQL Server will lose
all Session values. If you use InstallPersistSqlState, the Sessions can't be
lost. However, I would think that Network issues could have an impact as
well, as the SQL Server is most likely not the same machine as the web
server.

Also, are you using a Web Farm scenario? Configuration issues can cause
problems with a Web Farm.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
T

TPS

Patrick, you need to dig down into your machine.config and make the
application name that same for each server.

If you look in your sql server session tables you will see 2 session records
for each session because you have two servers servering up web pages.

email me if you want more detail.

Take the numbers out of my email address.

(e-mail address removed)

TPS.
 
T

TPS

Patrick,
I am assuming you are using load balancing if you are using two servers in
your application correct? If so...

I steered you wrong last night with this statement:
If you look in your ASPState database and view the ASPTempApplications
table,
you will probably have two rows. One for each server. This is bad. Now
look
in the ASPTempSessions table and notice you probably have 2 rows for each
sessionID. Each server is holding it's own session, yet there should be
only
one session.


You need to sync the application names in the IIS metabase.
Get ahold of a copy of MetaEdit (search ms site) and make sure
this # (1751721335) is the same on all servers in this key.
LM\W3SVC\1751721335\root\

It does not have to be the number in this example, just make sure they
are the same on both of your servers.


1. Syncronize application names in the IIS metabase.
LM\W3SVC\1751721335\root\
key name: approot value = /LM/W3SVC/1751721335/Root
Make the above keys the same on all servers using metaedit.exe

2. Syncronize encryption keys across all web servers

a. Generate a key by running
E:\Source\DOTNET\CPO\HashConfigCs\bin\Debug\HashConfigCs.exe and pass these
args 24 64

See this article http://support.microsoft.com/?id=312906

b. Paste output from the above program into the machine.config on each
machine

<machineKey
validationKey="FED661660E09167F30CCFFF4E5DADF3E036FD7712E7B187762FF32B918BC3
CA8FC1A751F3F7EFAD0A48AAC4DB90DDDD639E82B96632796B416A64ABA1EF29A6F"

decryptionKey="DCB56D6EC85B79DF7DCD85F45F775B6AB016ABB3BE5C5E2C"
validation="SHA1"/>

Hope this helps,
TPS
 
P

Patrick

Hi

Thanks for your Email. I checked my configuration, and I have the same
number for both webservers, it's different than yours, but it's the same. So
I also have only 1 entry in the ASPTempApplications Table. I also tried to
to connect to one website, then to the other, I don't loose the Session. But
what I've different is the machine.config...

here i have:

<machineKey validationKey="AutoGenerate,IsolateApps"
decryptionKey="AutoGenerate,IsolateApps" validation="SHA1"/>

should I change this to yours? Can this be the reason why sometimes sessions
are just dropped? I'ts 100% sure not the session-timeout.

I just have this problem since using the Session in the SQL Server.

Any other good ideas?
Thanks a lot
 
P

Patrick

Hi

Thanks for your Email. I checked my configuration, and I have the same
number for both webservers, it's different than yours, but it's the same. So
I also have only 1 entry in the ASPTempApplications Table. I also tried to
to connect to one website, then to the other, I don't loose the Session. But
what I've different is the machine.config...

here i have:

<machineKey validationKey="AutoGenerate,IsolateApps"
decryptionKey="AutoGenerate,IsolateApps" validation="SHA1"/>

should I change this to yours? Can this be the reason why sometimes sessions
are just dropped? I'ts 100% sure not the session-timeout.

I just have this problem since using the Session in the SQL Server.

Any other good ideas?
Thanks a lot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top