In a C# ASP .NET application I have a web service that receives a DataSet, processes it, and returns it.
Returning it can take up to a minute over a slow connection. What happens in the background if that connection breaks after the last line of the web service method has run but while the data is still being sent?
I tried wrapping my web service's code in a catch block and disconnecting the connection while it was downloading, but no exception was thrown in the web service. I'd to detect the error somehow like this:
[WebMethod(Description = "Process data")]
public DataSet Process(DataSet data)
{
bool success = true;
StartDatabaseTransaction();
DataSet result = Process(data);
try
{
return result; //quickly pull out cable after running this
}
catch
{
success = false; //never gets here
}
finally
{
if (success) CommitTransaction(); else RollBackTransaction();
}
return null;
}