Reputation: 43863
If they close the browser page out after a process has started via a button on the page, will the process keep running until completion or will it die? How will I allow it to die safely if so?
Upvotes: 0
Views: 177
Reputation: 22655
The page will keep processing. If you want to terminate the processing you can check the HttpResponse.IsClientConnected property and end processing if the client is no longer connected.
The example from MSDN:
private void Page_Load(object sender, EventArgs e)
{
// Check whether the browser remains
// connected to the server.
if (Response.IsClientConnected)
{
// If still connected, redirect
// to another page.
Response.Redirect("Page2CS.aspx", false);
}
else
{
// If the browser is not connected
// stop all response processing.
Response.End();
}
}
However that assumes that are able to check the property. If you make a long running synchronous call then you wouldn't be able to check the property. If that is the case you can either execute it asynchronously or break the long running call into separate smaller calls where you can check the status before processing further.
Upvotes: 4
Reputation: 17022
I would say, off hand, that that depends entirely on the process and how you've coded your solution.
In my experience, however, there's no direct connection between the browser and the server. It's simulated through the use of session state. So once that process starts, I'd say yes, it will keep going until it sends the response back to the client. Whether or not the client is there to receive it is another matter altogether.
Upvotes: 1