Questions tagged [session-state]

Session-state allows the retrieval of values for a given user as that user navigates through a website. It is used to maintain state across a visit within the constraints of the stateless HTTP protocol. Session-state is commonly abbreviated to session.

ASP.NET session state supports several different storage options for session data. Each option is identified by a value in the SessionStateMode enumeration. The following list describes the available session state modes:

  • InProc mode, which stores session state in memory on the Web server. This is the default.
  • StateServer mode, which stores session state in a separate process called the ASP.NET state service. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
  • SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
  • Custom mode, which enables you to specify a custom storage provider.
  • Off mode, which disables session state.

You can specify which mode you want ASP.NET session state to use by assigning a SessionStateMode enumeration values to the mode attribute of the sessionState element in your application's Web.config file. Modes other than InProc and Off require additional parameters, such as connection-string values as discussed later in this topic. You can view the currently selected session state by accessing the value of the HttpSessionState.Mode property.

Check more details in the follow link - Session-State Modes

1902 questions
49
votes
3 answers

ASP.NET: How to access Session from handler?

i'm trying to store some values in the Session from a Handler page, before i do a redirect to a WebForms page, that will pick up the Session values and pre-fill the WebForm: public class Handler : IHttpHandler { public void…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
48
votes
1 answer

Replacing ASP.Net's session entirely

ASP.Net session appear perfect for a traditional WebForms app, but they do some things that are a serious problem for a modern AJAX and MVC application. Specifically there are only 3 ways to access the ASP.Net provider: Locking read & write…
Keith
  • 150,284
  • 78
  • 298
  • 434
46
votes
2 answers

Session.Clear() vs. Session.RemoveAll()

Is there a difference between Session.Clear() and Session.RemoveAll()? The descriptions and documentation pages seem to say exactly the same thing, but I am assuming there must be some reason for creating two functions, am I right?
Nishant Kumar
  • 5,995
  • 19
  • 69
  • 95
40
votes
6 answers

When the same user ID is trying to log in on multiple devices, how do I kill the session on the other device?

What I want to do is to limit a user ID to only being able to log in to one device at a time. For example, user ID "abc" logs in to their computer. User ID "abc" now tries to log in from their phone. What I want to happen is to kill the session…
38
votes
1 answer

How to manage state in REST

I guess this question will sound familiar, but I am yet another programmer baffled by REST. I have a traditional web application which goes from StateA to StateB and so on. If the user goes to (URL of) StateB, I want to make sure that he has visited…
user317050
  • 383
  • 1
  • 4
  • 4
37
votes
2 answers

Why Session is a disaster in ASP.NET MVC application?

Why is it being said We should not use Session variables in ASP.NET MVC applications ? I came across this answer which says so. In that case how will i maintain the values across requests like Logged in User information and some relevant data…
Happy
  • 1,767
  • 6
  • 22
  • 26
33
votes
5 answers

Maintaining session in android ( application stay authenticated on the server side)

I am building a login application in android in which i am hitting a url(with username and password) upto that part it works fine but after that whenever I am hitting a url(once the user is authenticated) , it return nothing(i.e. a error message…
Dinesh Sharma
  • 11,533
  • 7
  • 42
  • 60
33
votes
4 answers

Why would ASP.NET MVC use session state?

Recommended by the ASP.NET team to use cache instead of session, we stopped using session from working with the WebForm model the last few years. So we normally have the session turned off in the web.config But, now…
Ray
  • 12,101
  • 27
  • 95
  • 137
33
votes
6 answers

HTTP Session Tracking

Since HTTP is a stateless protocol, when a client makes a number of requests to the server, how does the server uniquely identify a particular client's requests over a period of time say t1, t2, t3.. I browsed the web and came across terms like…
dexter
  • 13,365
  • 5
  • 39
  • 56
31
votes
3 answers

SignalR doesn't use Session on server

When I try to access the HttpContext current session from the HUB it returns null. I tried making use of the interface IRequiresSession but it didn't work. Can someone help me?
Danillo Corvalan
  • 703
  • 1
  • 10
  • 19
30
votes
2 answers

What are the benefits of a stateless web application?

It seems some web architects aim to have a stateless web application. Does that mean basically not storing user sessions? Or is there more to it? If it is just the user session storing, what is the benefit of not doing that?
Genadinik
  • 18,153
  • 63
  • 185
  • 284
29
votes
6 answers

Generating a new ASP.NET session in the current HTTPContext

As a result of a penetration test against some of our products in the pipeline, what looked to be at the time an 'easy' problem to fix is turning out to be a toughy. Not that it should of course, I mean why would just generating a brand new session…
Rabid
  • 2,984
  • 2
  • 25
  • 25
28
votes
1 answer

Writing to a read only session in MVC 3+

I've come across a curious behaviour of ASP sessions. You can force a controller to be outside of the user's session - I want to be able to do this so that multiple requests can execute at the same time and using a session causes them to execute…
Keith
  • 150,284
  • 78
  • 298
  • 434
27
votes
4 answers

ASP.NET session state and multiple worker processes

I need to understand something about ASP.NET session state, as it applies to IIS 7 and ASP.net 3.5. If an application is configured to use in-process session state, will that work OK if there are multiple worker processes? In other words, do worker…
Tim Long
  • 13,508
  • 19
  • 79
  • 147
26
votes
1 answer

How does the session timeout work in IIS 7?

In web.config, I set timeout in the sessionState to 20 minutes. According to MSDN, this timeout specifies the number of minutes a session can be idle before it is abandoned. In IIS 7, DefaultWebSite->Session State->Cookie Settings->Time Out…
GLP
  • 3,441
  • 20
  • 59
  • 91