background process - Can an ASP.NET page do some of its processing after the page finishes loading? -
I have an asp.net page that is taking too long to load. A little test shows that server side logging is taking a fair share of time and (because the user never needs to see the logging result) I will delay it till the page is loaded. Want to
Is there an easy way to do this?
I have tried to put it in the Disposed
event of the page but it is not visible in the fire Unload
event but it will also soon fire It seems that I do not need to lay eggs on any thread, but I can do it if it is the same.
I'm looking for not AJAX. I want to load a normal full page and after processing the page (as seen from the client side) do a bit more processing.
This appears to be working:
protected void Page_Unload (Object Sender, EventArgs E) {HttpContext.Current.Response.Flush (); HttpContext.Current.Response.Close (); Thread.Sleep (20000); // Process to sleep place here :) Debug. WrightLine ("Done!"); }
You mentioned that the unload event has started to fire very soon, but I think it's at the right time. You need to manually close the connection. Flushing also seems compulsory, which is a bit weird, as I thought, when you are closed, a flush is embedded.
There may be some downside in it, because this request keeps the process busy, unable to handle the next HTTP request IIS 7 has a configuration limit on the number of requests simultaneously. , I think it's as easy as it will get.
Comments
Post a Comment