Session - Difference Between "InProc" And "stateServer" Mode In SessionState?
May 25, 2010like the title shows I want to know what is the difference between "InProc" & "stateServer" mode in SessionState on ASP.NET.
View 2 Replieslike the title shows I want to know what is the difference between "InProc" & "stateServer" mode in SessionState on ASP.NET.
View 2 RepliesMy session variables don't get saved if the SessionState mode in the web.config file is set to StateServer. But when I changed it to InProc, then everything is fine and good. I'm trying to save a custom built object (or class) into the session after the user logs in.
View 4 RepliesI have an asp.net site that's basically a giant form for users to submit weekly turkey information for their starter and finisher houses. I use session variables so the information is viewable to a "Review" page. There have been 3 instances where the users would try to submit their information but kept losing their information. As far as I know, they are not letting the page sit idle for more than 20 minutes. I tested it out myself and lost session variables after less than 10 minutes. My sessionState mode is InProc. Should I look into switching to StateServer? If so, how would I do this?
[Code]....
Just wanted to know in which type of web application we can use out proc session state mode?
View 2 Replieshow to made session timeout in INPROC mode
View 5 RepliesIs it possible to build a fully customized Session State Mode instead of using Inproc or SQLServer?
View 1 RepliesI am new to .net 4.0 and am using EF Model and SessionState Mode=SqlServer and I am getting this error below:
Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
I checked the stack trace and its complaining about
[assembly: global::System.Data.Objects.DataClasses.EdmSchemaAttribute()]
[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("PoplarGroveModel", "tblMenuRole", "tblMenu", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(PoplarGroveDataModel.Menu), "tblRole",
[Code].....
I marked it as serializable but then it complains about System.Data.Objects.ObjectContext is not marked as serializable and hence throws the same error.
I have checked the servers (Win Server 2003) application event logs for the following problem [URL] which doesn't show up. It just appears that sessions drop randomly for random users
It's a single server setup, no web farms and no load balancing
Even though the issue I point to above doesn't occur in the logs, is it worth increasing the stateNetworkTimeout attribute anyway? The configuration at the moment is simply
<sessionState mode="StateServer" cookieless="false" stateConnectionString="tcpip=localhost:42424" timeout="60"/>
UPDATES:
Using FormsAuth and the Timeout is set to 60
IIS6 Settings
Recycle worker processes (in minutes) = 120
Recycle worker processes (number of requests) = 35000
Recycle worker processes at the following times = Unchecked
Maximum virtual memory = Unchecked
Maximum used memory = Unchecked
Shutdown worker processes after being idle = 90
Limit the kernel request queue = 1500
Everthing else = Unchecked
There are reams of info out there about things causing InProc session to drop session objects, but that's not what's happening here. We're missing individual variables within stable InProc session objects, and are not sure whether they're not being written or being lost after a successful write. I've confirmed with WinDBG that the sessions are live and contain some, but not all, of the data written to them.
Guid g = System.Guid.NewGuid();
this.Context.Session.Add(g.ToString(), result.ImageData);
output.Write("<img src="display.aspx?id=" + g.ToString() + "">");
This code is pretty straightforward, and it works flawlessly in Test. In Production, under heavy load, though, it fails ~1% of the time. If Mr Smith visits the site and attempts to display 4 pieces of image data, 2 of them might be saved in his session and two of them be lost. The InProc session object for Mr. Smith exists. The traffic logs show he clicked 4 times, each with a different id param. But there are only 2 guids in his InProc session object, instead of 4. The 2 session objects we did capture do correspond to 2 of the id's shown in the traffic log (his 1st and 3rd clicks.) The traffic logs for his 2nd and 4th clicks, though, show a guid id that's not in his InProc session object.
Lines 1&3 of the above code obviously worked for those 2nd and 4th clicks, or he'd not have had the id in the URI for him to click. Line 2, however seems to have failed silently in some way. If any exception had been thrown, I'd expect we'd not ever have arrived at line 3. I can't see any way for the user to receive the guid id, but the session to fail to have it. The other possibility is line 2 worked successfully, but the variable later disappeared, how I cannot even imagine.
Details:
ASP.NET v3.5
IIS 6
No Web Gardening
We're running a web farm, but users constantly return to the same server. I'm researching now whether there's any way users might be slipping off to the other server.
I have been thinking of ways to optimize the out of state storage of sessions within SQL server and a few I ran across are:
Disable session state on pages that do not require the session. Also, use read-only on pages that are not writing to the session.
In ASP.NET 4.0 use gzip compression option.
Try to keep the amount of data stored in the session to a minimum.
Right now, I have a single object (a class called SessionObject) stored in the session. The good news is, is that it is completely serializable.
Optimizing using protobuf-net An additional way I thought might be a good way to optimize the storage of sessions would be to use protocol buffers (protobuf-net) serialization/deserialization instead of the standard BinaryFormatter. I understand I could have all of my objects inherit ISerializable, but I'd like to not create DTO's or clutter up my Domain layer with serialize/deserialize logic.
Is is possible to log when a session times out when a stateserver is used to manage session data?
View 2 RepliesI'm considering moving our web app session storage from In Proc to State Server. Can anybody give any figures as to the performance difference?
View 1 RepliesI'm reading ASP.NET 4 Unleashed and I came to this sentence. "When Session state is stored in-process, it is stored on a particular web server. In other words, you can't use in-process Session state with a web farm."I'm building a web app that uses and depends on storing dictionaries in the session. Now I know that there's some problem with serialization of dictionaries when using sessions but with InProc sessions, there's no serialization so I thought I'd be ok. But now I'm wondering: will I have any nasty surprise when I go to host my application?
View 1 RepliesI'm having trouble getting 2 identical ASP.NET MVC applications to share the same Session using a Session StateServer. The reason I'm trying to do this is we will eventually be deploying this app across 3 web servers that need to share the same state. We need to use StateServer because we are trying to minimise use of the db for non data-related storage.
The Setup: I've deployed the same code base to http://localhost/App1 and http://localhost/App2
both have identical Web.Config files with the following:
<system.web>
<sessionState mode="StateServer"
cookieless="false" [code]....
The Result:For both deployments, when the page first loads I can see that the mode is StateServer and the timestamp is getting set to the same time as the realtime value.. However, if this was working, only the first page should have the same time as the realtime value. The second page load should read from the StateServer because that timestamp value is no longer null, and display that time value. But instead, it's displaying the realtime value again.
When I refresh the page, I the timestamp stays the same and the realtime value is always updating. This indicates that the timestamp is being saved to the Session, but the time stamp value is always different for both deployments when it should be the same, so this indicates that the Session is not being shared.
Possible Duplicates: Debug/Release difference Performance differences between debug and release builds
What exactly is the different in compiling and running an asp.net/c# project in Debug mode VS Release Mode?
I've recently been tasked with fixing a rather nasty bug resulting from the misuse of session state. We have an asp.net web application that runs on a single sever using inproc session state. The basic design is that a typed dataset is loaded from the database and stored in session state using a common session variable name like Session["dataset"] = dataset. After the data is stored in the session the user edits the data, dataset is retrieved from the session updated and sent to the database for updating. This type of data editingstoring is used across multiple webforms that basically do the same thing. All is good until a user tries to launch a second instance of the application and data stored within the session variable can get mixed up. Here are the possible fixes that I've been able to find
Set sessionState cookieless="false" (every new instance gets a unique session id) PROS - easiest solution, almost no code changes needed CONS - guid in url, user can edit guid, guid can be copied Use a custom session key for every instance (pass a session key around and combine it the "dataset" + session key name so that each instance has a unique session variable) PROS - no guid in url CONS - most amount of code changes, possibly fragile Remove the session variable (Load the dataset from the database a second time for editing) PROS- frees up server resources, no longer dependent upon session state CONS - performance hit, high amount of code changes
i'm interested to do the following - i geuss, i have no option to do that:
we have our "mainapplication" on a DB; we are tracking user-login status by switching a bit in the DB in the users data row.
we hvae a second application, the backend, which is the administration tool.
(the applications are put in seperate diretories on HD)
sometimes, we need to block/ban users. in some cases the users are logged in, when we "see them in action".
i'd like to build a button in the backend-application, which logss-out the user from the mainapplication.
for sure: i can access the same DB and switch the bit to "know" he's offline, but this will not kill the session on the mainapplication.
because: if a user is on/offline is also indicated by the session in the IIS. and as the IIS-session is active, the user may be already banned - but he will not be logged out automatically (and showing something like "you have been logged out because of a ban) one option would be to call the DB by each page-load to find out, if the user is logged on.
I am working on a website and this is my first web project. Scenario for Session I have created a database for my project with security level little bit high. I want to manage session for each and every user who is logging in to my website. Session state can be used using Cookie as well as URL, only one at a time. Now I went over with all four session state modes. i.e 1. InProc 2. State Server 3. Sql Server 4. Custom
Now after reviewing from all these modes I am in confusion which one should I use Sql Server or Custom. Basically i want to store session related information in my own database instead of Aspnet_db which is a default database provided by microsoft. I have created all tables related to login and registration. But I dont know how to store session into my database. What tables do I need to create so as to maintain into database. I want to create a complete log of session and login related information into my database(Persistant atleast for 1 year). I want to use machinekey as AES and SHA1.
<sessionState mode="Custom" cookieless="AutoDetect" timeout="15" regenerateExpiredSessionId="true" stateNetworkTimeout="10" >
</sessionState>
<machineKey decryption="AES"
validation="SHA1"
decryptionKey="7E047D50A7E430181CCAF7E0D1771330D15D8A58AEDB8A1158F97EEF59BEB45D"
validationKey="68B439A210151231F3DBB3F3985E220CFEFC0662196B301B84105807E3AD27B6475DFC8BB546EC69421F38C1204ACFF7914188B5003C1DCF3E903E01A03C8578"/>
<add name="conString" connectionString="Data Source=192.168.1.5; Initial Catalog=dbName; Integrated Security=True;" providerName="System.Data.SqlClient" />
What all things do i need to specify in webconfig? My Data Source= 192.168.1.5 Database name= db.mdf What I need to know about. What tables do i need to add to my database to store session related information. eg. Session id (Any other field is also stored or not), Session Time, Session Start Time, Session End Time, Session Expire Time. I dont know what all things are usually taken. Do I need to encrypt Session Id
before storing into database. If Yes Encryption will be automatic or do i need to write some code to do this other than that I wrote in web config above. How mode='custom' will be used into web config using my database. in following code
<sessionState mode="Custom" cookieless="AutoDetect" timeout="15" regenerateExpiredSessionId="true" stateNetworkTimeout="10" >
</sessionState>
What is the difference between Session.Abandon() and Session.Clear() in ASP.Net?
View 1 RepliesWhy Session_End event occurs only in "InProc" mode not in "State Server" and "Sql Server"?
View 7 Repliesi'm using an example in which i can fake the session.It's for use in a unittest of a mvc controller.In the test i create a controller and then i do this:
FakeHttpContext httpctx = new FakeHttpContext(null,null,null,null,mSessionItems );
ControllerContext ctx2 = new ControllerContext(httpctx,new RouteData(), target);
here mSessionItems is my session and target is my instance of a controller,and indeed, when i'm in a controller reading this.ControllerContext.HttpContext.Session, i have a session, great!but.... i also read the session outside the controller, and there i use HttpContext.Current.Session, and that is null (or actualy, the HttpContext.Current is null).
What is difference between Session.Clear() vs. Session.Contents.Clear()?
I want to clear all the Session variables.
In ASP.NET, I'm a bit confused about role of cookies in session state. Whats is the difference between normal session state and cookieless session state?
View 5 Repliesi have a page alignment issue on my page below,the application i have developed by ASP.NETthe problem is i have a text box in this text box i have set the textmode in passwordmy problem is below,
ex:name =............ // normal textbox (width 168px)without using textmodepwd =........ // textmode =password (width 168px)
the moment is it was working fine on firefox and chrome perfectlybut IE am getting the above alignment issueactually i was set the both text box width is 168pxif i removed the text mode in password text box then it was working fine for both browserbut when i set text box mode am getting the above issue.
I know that Session is for a single user , and application is for multi user purpose.The Data in the application object is shared. Right? Then how can access the application data from an another client.
if My concept is wrong then what's right?