.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
sivanagamahesh
Post New Web Links

APPLICATION STATE AND SESSION STATE HELP

Posted By:      Posted Date: October 03, 2010    Points: 0   Category :ASP.Net
 

User Interface: 2 Labels;  1 Buttons

Requirements: Create a Web Page in ASPx that will do the following:

 

1)      One label will provide a count of how many times Button 1 has been clicked in the current session.

2)      One label will provide a count of how many times Button 1 has been clicked by all users of the application.

          The Application Code for the Button should start at 100 (set this in the Global.asax file).

 

this is what i have so far but i cant seem to get the application state to work properly.

aspx.vb


Partial Class _Default
    Inherits System.Web.UI.Page
    Dim clickcount As Integer


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Session("ClickCount") Is Nothing Then
            clickcount = 0
        Else
            clickcount = CInt(Session("ClickCount"))
        End If
  


View Complete Post


More Related Resource Links

Session State Expiration after Application pool recycle

  

Hello All we have a global ships position tracking website which runs smoothly until IIS application pool recycles.When there is workerprocess recycling looks like session state expires as a result i loose all session data and when customer clicks refresh button he is redirected to login page.

In web.config Session state mode is set to InProc so i changed it to State Server but to my luck i have MAP object which is not serialiazable which is causing the maps from not appearing on the website.I tried adding serializable attribute to the object class but still not succesfull.Our website is accessed by our customers whose count is more than 1000.

Changing the session state mode from InProc to StateServer can really slow down the response time so Is it good to go further fix the serailizable issues and move to state server?.

Is there any way I can retain my session data when application pool recyles?..

Stopping Application pool from recycling may not be a good idea considering health factor of web server.

 

Any Suggestions?..

 

 

 

 

 

 

 

 


Save Workflow Runtime as Application State or Session State for a website with multiple users?

  

I used Windows Workflow Foundation 3.5 as a page flow navigation for a ASP.NET website's Previous and Next page navigation.

The site acts like a shopping cart and each user has his own session and user data.  The app only has one WF.  I am not sure if I should generate one Workflow Runtime for every user or for simply generate one workflow Runtime for the entire application in my case?   

In the global.asax:

void Application_Start(object sender, EventArgs e)
    {
       
    } 

void Application_End(object sender, EventArgs e)
    {
                         
    }
    
    void Session_Start(object sender, EventArgs e)
    {
        // Code that runs when a new session is started
        System.Workflow.Runtime.WorkflowRuntime workflowRuntime = new System.Workflow.Runtime.WorkflowRuntime(WorkflowManager.WorkflowRuntimeKey);

      

SQL Server Session state problem.

  

Hi to all,


I have some things that I want to know. I am right now using a free asp.net webhosting ("somee.com"). The problem is that when I am visiting a page, there's a tendency that values stored in my session variables are lost. Therefore, it causes an error when the requested page is loaded.

1. I am thinking of using sessionState mode="SqlServer". Will it solve my problem?

Actualy Im working on it but Im having problems when connecting to the sql database.

2.  Is that a problem in the webhost?

3. Do free webhosting sites provide allow session state in the sql server?. Because ive tried it locally into my computer and error say's i should intall the ASP.NET Session State SQL Server version 2.0 or above.




Best Practices: Fast, Scalable, and Secure Session State Management for Your Web Applications

  

ASP.NET provides a number of ways to maintain user state, the most powerful of which is session state. This article takes an in-depth look at designing and deploying high-performance, scalable, secure session solutions, and presents best practices for both existing and new ASP.NET session state features straight from the ASP.NET feature team.

Mike Volodarsky

MSDN Magazine September 2005


ASP.NET: Nine Options for Managing Persistent User State in Your ASP.NET Application

  

ASP.NET provides many different ways to persist data between user requests. You can use the Application object, cookies, hidden fields, the Session or Cache objects, and lots of other methods. Deciding when to use each of these can sometimes be difficult. This article will introduce the aforementioned techniques and present some guidelines on when to use them. Although many of these techniques existed in classic ASP, best practices for when to use them have changed with the introduction of the .NET Framework. To persist data in ASP.NET, you'll have to adjust what you learned previously about handling state in ASP.

Steven Smith

MSDN Magazine April 2003


Taming the Stateless Beast: Managing Session State Across Servers on a Web Farm

  

Running a Web farm means managing session state across servers. Since session state can't be shared across a Web farm with Internet Information Services 5.0, a custom solution is required. One such solution using a tool called the session manager is described here. The article begins with a description of the SQL Server database used to store state information, the stored procedures used to update it, and the retrieval of session data. ASP code drives the session manager tool and the COM and COM+ components that run the stored procedures.

John Papa

MSDN Magazine October 2000


Session State Problem

  

Hi,

 

I just for the first time into a session state problem. So I am hoping someone

here has the answer.

 

I have written an ASP.Net website and tried to implement the common poor mans online user count.
The problem I am having is the following.

On App_Start I create a variable and assign it the value of 0;

Then increase the number on session_start and decrement on session_end.

On my local IIS it works perfectly from IE8 and Opera. The value increments correctly.
As soon as I upload to my live server. The value increments on every link I click and every page refresh when I test with IE8.
This does not happen when testing with Opera.

Could someone please shed some light on the subject.

 

Thanks

 

Louis Lews


Good news for those of you who get "Unable to make the session state request to the session state se

  

Dear all,

Due to the known problem of session variables getting lost if using InProc-server during frequent changes in development, I had to choose between SQL and ASP.NET State server, so I opted for the second. Initially, all fine, but after using it for a few days, I started to get this error:

 Server Error in '/cv2' Application.
Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the clie

How to use cookieless session state...

  
I want to know how its work and it advantage and disadvantegePls explain me with example

Session State for Listview Items?

  
Hi, I have a listview control, in it each item will have a checklist eg - Pass / Fail which will then have a label displaying the selected value. I also have datapager wired up to the listview. When i toggle between the datapages and toggle back, any result previously submitted will be wiped. I am thinking i should be using session state to temporarily store then info, and then once the session is finished use a submit button to send all values and ids into an xml. 1. Is this the right way of approaching the situation? 2. How would i specify session state for listview items, eg would i angle it through a itemdatabound event or the application itself?   Any assistance and advice would be appreciated as i have only started looking at state management and xml storage.  

Accessing Session State in a User Control

  
We have a web site that implements a custom SiteMapProvider using a User Control added in the master page. I need to be able to limit the sitemap nodes added depending on the logged in user, that is, certain users should not see certain sitemap nodes. Currently, the login processing code determines if users are in the certain category or role and then sets a value in session state, for example, Session["UserInRoleXXX"] = "Yes"; I tried changing the code in the user control to check the session state, but I got the following error: NullReferenceException ... Object reference not set to an instance of an object." Can session state be accessed in a user control? If so, how? If not, any suggested solutions? Thanks in advance for any help.

Session state and MVC

  
I'm trying to maintain session state for a user with MVC.  What is the best approach?

Help with THREADING and SESSION STATE

  
I created a page which runs a THREAD.  Unfortunately, at the end of the THREAD which is designed to populate a table, an error is produced.  It says that the SESSION STATE CAN ONLY BE USED WHEN ENABLESESSIONSTATE IS SET TO TRUE.  I added the ENABLESESSIONSTATE to my page directive.  However, it seems that this does not suffice.  It also says the I need to add a CUSTOM SESSION STATE module in the CONFIGURATION section.  Is there an example of where I do this in the WEB.CONFIG.  I need a fairly detailed WEB.CONFIG as I don't want to break what I have at the moment. TIAJohn

What are the benefits of using ASP.NET Session State in a Web Service

  
I have a question regarding session state usage in a  Web Service method. I thought about this situation as I came across an article http://msdn.microsoft.com/en-us/library/aa480509.aspx Situation is that A. There are web service methods which are being exposed. One web method to store value in a session state and another to get value from session state. B. There is another asp.net website which calls the above web methods.        B                    ----------------------------------->       A (Another ASP.NET Website)                 (WebService hosted in an ASP.NET website)   Questions: Does webmethod can store data in a session variable in Webservice application's IIS (in Proc)? I tried this (refer below code snippets) but I was not able to store and get data thru webmethods into/from state. Why?? What is the use of storing it in the state of the Webservice's website IIS (in proc). Will there be any session objects create due to any web service calls from clients? What are the benefits of saving a value in WebService's session, not in the calling website's session. A WebService's webmethod can able to use session state, does that mean that a session will b

What are the benefits of using ASP.NET Session State in a Web Service?

  
I have a question regarding session state usage in a  Web Service method. I thought about this situation as I came across an article http://msdn.microsoft.com/en-us/library/aa480509.aspx Situation is that A. There are web service methods which are being exposed. One web method to store value in a session state and another to get value from session state. B. There is another asp.net website which calls the above web methods.         B                    ----------------------------------->       A (Another ASP.NET Website)                 (Web Service hosted in an ASP.NET website)      Questions: Does web method  can store data in a session variable in Web service application's IIS (in Proc)? I tried this (refer below code snippets) but I was not able to store and get data thru webmethods into/from state. Why?? What is the use of storing it in the state of the Webservice's website IIS (in proc). Will there be any session objects create due to any web service calls from clients? What are the benefits of saving a value in Web Service's session, not in the calling website's session. A Web Service's web method can able to use sessio

Session state just got screwed up between pages

  
I had a website that was working fine for months and now an external consultant played with IIS 6 and now every once in a while when I open a new page, the session is gone (same browser, sometimes a new window, sometimes the same).   As far as I can see the timeout is correct when I ping the Session.Timeout on page load.   What could be causing this??
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend