Link to home
Start Free TrialLog in
Avatar of critto
crittoFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Asp.net MVC Session

Hi Experts,

I have an asp.net MVC application that I have released to a test server online. On my dev machine it works fine, but online, I lose session after a few minutes.

can anyone tell me how to either persist my session variables until the end of the browser session, or if I should pass it out to a cookie.

I am dealing with extremely sensitive info ( medical records ) so security is of the essence.

Critto.
Avatar of rdogmartin
rdogmartin
Flag of United States of America image

Chances are your application domain is recycling. There are many reasons why this might happen - here is a good blog post about it.

One easy workaround is to use the ASP.NET State Service rather than the in-memory session. Configure the ASP.NET State Service to run automatically in the Services applet, then open web.config and update the <sessionState> element to  this:

<sessionState  mode="StateServer" stateConnectionString="tcpip=127.0.0.1"  cookieless="false" timeout="60"/>

Cheers,
Roger
Avatar of critto

ASKER

Hey thanks for your post Roger. Just one question:

"Configure the ASP.NET State Service to run automatically in the Services applet."

How do I do this part??
Either that or you are working in a load balanced environment and you are hitting different servers. If that is the case you will need to make sure you use a common state server.
Avatar of critto

ASKER

I'm being hosted on a commercial server, most probably a virtual machine. My utmost concern is security. I cant have any persisted information. What should I do in this case with my session persistence, without compromising 1. security, and 2. my session persistence.

Im playing with <sessionState mode="InProc" timeout="60" cookieless="UseUri" /> now to see if i can get around my session dying.

It is likely that I will need to persist over a clustered environment once I get past testing on my commercial host, so can you give me any tips on best practice that will work on both?
If you can't store anything then does that mean that your application does not use a DB server?
Avatar of critto

ASKER

Hi James, apologies.. No I mean't that just session info shouldn't be persisted to a client in any form that's all. I just realised I didn't mention this, but it's an asp.net mvc application. it's connected to an sql server 2008 database.
ASKER CERTIFIED SOLUTION
Avatar of jamesbaile
jamesbaile
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of critto

ASKER

thanks guys, I'm going to use sql server for storing session state.