[Mono-dev] PR 1359: System.Web.HttpApplication: set StatusCode = 500 when we send an exception to the client

Martin Thwaites monoforum at my2cents.co.uk
Fri Oct 24 13:18:31 UTC 2014


Is this something that we can unit test to verify against .Net?
On 24 Oct 2014 13:26, "Etienne Champetier" <champetier.etienne at gmail.com>
wrote:

>
>
> 2014-10-24 13:53 GMT+02:00 Etienne Champetier <
> champetier.etienne at gmail.com>:
>
>> I know nothing about customerrors,
>> but we are in the init so we may have fail to parse the config,
>> so using customerror here is dangerous
>>
>>
>> Exception e = initialization_exception;  HttpException exc =
>> HttpException.NewWithCode (String.Empty, e,
>> WebEventCodes.RuntimeErrorRequestAbort);  + context.Response.StatusCode
>> = 500;  FinalErrorWrite (context.Response, exc.GetHtmlErrorMessage ());  PipelineDone
>> ();  return;
>>
>> static void FinalErrorWrite (HttpResponse response, string error)  {  try
>> {  response.Write (error);  response.Flush (true);  } catch {  response.
>> Close ();  }  }
>>
>> The only think that i'm sure of is that we are sending an exception with
>> http 200 :)
>>
>> I can replace 500 with exc.GetHttpCode() if you prefer?
>>
>
> Forget about this, this will send 501 Not Implemented, i prefer 500
>
>
>>
>>
>> 2014-10-24 13:33 GMT+02:00 Martin Thwaites <martin at my2cents.co.uk>:
>>
>>> Does this need to take into account the customerrors setting in the
>>> Web.config or is that handled further down the pipeline?
>>> On 24 Oct 2014 09:57, "Etienne Champetier" <champetier.etienne at gmail.com>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> when we get an exception in InitOnce (in HttpApplication), we send this
>>>> exception to the browser, without changing StatusCode so we get a wonderful
>>>> http 200.
>>>>
>>>> I've checked and it's the only place where we call FinalErrorWrite and
>>>> we didn't set StatusCode.
>>>>
>>>> https://github.com/mono/mono/pull/1359
>>>>
>>>> Bye
>>>> Etienne
>>>>
>>>>
>>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20141024/8e051a76/attachment.html>


More information about the Mono-devel-list mailing list