Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Unassigned: Exception inside PushStreamContent won't be caught by ExceptionFilterAttribute? [1089]

$
0
0
Hi,

I'm using PushStreamContent in asp.net web api to stream data to the client, I have derived from ExceptionFilterAttribute to capture all the exceptions and return standard HttpError to client. However,
I found that exception thrown inside PushStreamContent won't be caught by ExceptionFilterAttribute, it will return a "text/html" error message to client.
Below is the sample code:

response.Content = new PushStreamContent(
async (outputStream, httpContent, transportContext) =>
{
try
{
// do something and throw exception here

}
catch (Exception ex)
{
throw;
}
finally
{
outputStream.Close();
}
});
Comments: The best thing that Web API could do here is to Abort the connection. Workaround: Call "HttpContext.Current.Request.Abort()" when an exception occurs to cause the connection to be closed. This way the client would know that a problem has occurred at the service.

Viewing all articles
Browse latest Browse all 7215

Trending Articles