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.
crittoAsked:
Who is Participating?
 
jamesbaileConnect With a Mentor Commented:
If you use the the session state server then the only information that is stored in the client browser is the session id token. However any session data is stored server side by the state server including TempData if you are using the default TempDataProvider
0
 
rdogmartinCommented:
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
0
 
crittoAuthor Commented:
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??
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
jamesbaileCommented:
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.
0
 
crittoAuthor Commented:
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?
0
 
jamesbaileCommented:
If you can't store anything then does that mean that your application does not use a DB server?
0
 
crittoAuthor Commented:
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.
0
 
rdogmartinConnect With a Mentor Commented:
To start the ASP.NET State Service, open the Services applet by typing services.msc in the Start bar or at the Start - Run prompt. Then look for the ASP.NET State Service in the list of services. Right click it and choose Properties. Change its startup type to Automatic and then manually start it.

The state service is compatible with a web farm as long as you point all the stateConnectionString values to the same server.
0
 
crittoAuthor Commented:
thanks guys, I'm going to use sql server for storing session state.
0
All Courses

From novice to tech pro — start learning today.