C
C#5mo ago
SiloCitizen3

Safe to use Response.OnCompleted ?

I've inherited a dotnet core codebase, hosted in elastic beanstalk, on linux, using nginx as a reverse proxy. One of the controllers has Response.OnCompleted which I've never encountered before...seems to be documented...seems to be supported, but never seen in any other project I've worked in. Is it safe to use? or is it an absolutely bad idea?
2 Replies
Angius
Angius5mo ago
Never seen it used either, but it does seem safe to use, shouldn't cause any issues Not sure what exactly would you use it for, but I guess it might be useful if you want to, dunno, run some cleanup after the response is sent, or log the success, or some such As long as you use .NET version higher than 2.x, since it seems that version and below had some issues
SiloCitizen3
SiloCitizen34mo ago
yeah, i came across that 2.x caveat where it didnt actually finish sending the response before doing the work, so it would hang until the delegate completed. Thanks!