This example illustrates how you can inform your users about a server-side process when an operation initiated by a callback request takes too much time.
In this example, a callback panel sends a request to the server and performs a long server process.
Another callback panel sends a callback to the server every timer tick. On the server, a callback event handler gets the current operation progress and returns this value to the client.
This approach does not work if the Session state is used. The Session state blocks parallel execution and forces parallel requests to be executed one after another because the access to the ASP.NET Session state is exclusive per session.
To avoid this issue, you can disable the Session state in the following ways:
-
At page level, set the
EnableSessionState
property toFalse
:<%@ Page Language="C#" AutoEventWireup="true" Inherits="_Default" EnableSessionState="False" CodeFile="Default.aspx.cs" %>
You can also set the page
EnableSessionState
property toReadOnly
. In this case, the Session state is enabled but not writable. -
At project level, set the
sessionState
mode key tooff
in the Web.config file:<system.web> <sessionState mode="Off"></sessionState> </system.web>
Note that when the Session state is disabled, it is no longer possible to use Session variables. The states below can be used as alternatives:
- Application state that stores variables that can be accessed by all users of an ASP.NET application.
- Profile properties that persist user values in a data store without expiring them.
- ASP.NET caching that stores values in memory available to all ASP.NET applications.
- Cookies.
- Query string that is available from an HTTP request.
- How to display progress information about server-side callback processing (MVC)
- How to track progress of server side processing on the client side (using HttpHandler)
- How to track progress of server side processing on the client side (using HttpModule)
- Progress Bar for ASP.NET Web Forms - How to use the WebMethod attribute to display the progress of a server-side process on the client