Featured post
c# - How to send a Status Code 500 in ASP.Net and still write to the response? -
i have asp.net single-file web service (a .ashx
file containing ihttphandler
implementation) needs able return errors responses 500 internal server error status codes. relatively straightforward thing in php:
header("http/1.1 500 internal server error"); header("content-type: text/plain"); echo "unable connect database on $dbhost";
the asp.net (c#) equivalent should be:
context.response.statuscode = (int)httpstatuscode.internalservererror; context.response.contenttype = "text/plain"; context.response.write("unable connect database on " + dbhost);
of course, doesn't work expected; instead, iis intercepts 500 status code, trashes whatever i've written response
object, , sends either debug info or custom error page, depending on how app configured.
my question - how can suppress iis behaviour , send error information directly ihttphandler
implementation?
this app port php; client-side written, i'm stuck spec. sending errors 200 status code sadly doesn't fit mould.
ideally, need control behaviour programmatically, because part of sdk want distribute without "edit file" , "change iis setting" supplementary instructions.
thanks!
edit: sorted. context.response.tryskipiiscustomerrors = true
ticket. wow.
context.response.tryskipiiscustomerrors = true
- Get link
- X
- Other Apps
Comments
Post a Comment