c# - Delegating Handler in ASP.Net Web API returning incorrect status code -


i have asp.net web api following delegating handler:

public class authenticationhandler : delegatinghandler {     public ilogger logger { get; set; }     public authenticationhandler(ilogger logger)     {         this.logger = logger;                 }      protected override task<httpresponsemessage> sendasync(httprequestmessage request, system.threading.cancellationtoken cancellationtoken)     {         x509certificate2 certificate = request.getclientcertificate();          if (certificate == null)         {             logger.logwarning("no certificate found on request.");             return task<httpresponsemessage>.factory.startnew(                 () => request.createresponse(httpstatuscode.unauthorized));          }          if (!isvalidcertificate(certificate))         {             logger.logwarning("certificate found on request not valid. thumbprint : " + certificate.thumbprint);             return task<httpresponsemessage>.factory.startnew(                 () => request.createresponse(httpstatuscode.unauthorized));         }     } } 

the handler registered in global.asax.cs. site hosted in iis 8.5. problem instead of returning unauthorized in case of wrong certificate, returning status of 500 internal server error on client side. there no issue correct certificate. also, there seems no exception, if put code block in try/catch. while debugging, code returns async task unauthorized status code, client receives 500. no error logged in event viewer. web api using .net 4.5.1.

is there missing? appreciated.

system.net.http.formatting assembly issue. checked in version 5.2.2.0 while system looking 5.2.0.0. added assembly binding redirect in web.config , solved issue. issue uncovered getting response fiddler suggested @fals. server side debugging didn't help.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -