ASP.NET Web Forms - How to use HTTP handlers to display the progress of a server-side process on the client
This example demonstrates how to use an HTTP handler to get information about the current progress from the server and display it on the client without refreshing the whole page.
Declare a custom HttpHandler class to send a request from the client to the server and return information about the current progress without refreshing the whole page.
public class TestHandler : IHttpHandler, IRequiresSessionState {
String GetProgress(HttpSessionState session) {
if(session == null || !(session["_Operation"] is Operation))
return "NaN";
var progress = (session["_Operation"] as Operation).Progress;
return progress.ToString();
}
public Boolean IsReusable {
get { return false; }
}
public void ProcessRequest(HttpContext context) {
var response = GetProgress(context.Session);
context.Response.CacheControl = "No-cache";
context.Response.Write(response);
}
}
Note
After you create a custom HttpHandler class, register it in the Web.config file. For more information, refer to the following article: How to: Register HTTP Handlers.
- Operation.cs (VB: Operation.vb)
- TestHandler.cs (VB: TestHandler.vb)
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
- ASP.NET Web Forms - How to display progress information about server-side callback processing
- 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
(you will be redirected to DevExpress.com to submit your response)