ServiceStack always return 200 with blank content


We have a problem with one of our IIS server which suddenly all request to ServiceStack path return with status 200 and with no response body (no data). It returns immediately and when we dump the w3wp we see the null pointer exceptions in the ServiceStack.HttpHandlerFactory.GetHandler method. And it seems that the reason every request return blank with status 200 immediately.

And also the problem only happen with Service Stack endpoint. Others request handle by MVC works fine.

Could you please give me some advise on how we can fix that issue. Below are the information about our application

Windows Servers 2016 IIS 10
ASP.NET MVC with ServiceStack 5.4

Not sure what could cause this.

First step is trying to identify it, hopefully by finding the StackTrace of the Exception. The /favicon.ico Exception is likely coming from MVC where it tries to match a controller with the automated browser requests for favicon.ico.

Does the HTTP Header include a X-Powered-By: ServiceStack/... Header? If not the Request may not be handled by ServiceStack. Are any IIS Exceptions being reported in the Windows Event Viewer or in the IIS Logs?

Do you have any logging enabled? and does it contain any Exception StackTraces that could cause this?

Can you catch the Exception with a registered UncaughtExceptionHandlers?

public override void Configure(Container container)
    //Handle Unhandled Exceptions occurring outside of Services
    //E.g. Exceptions during Request binding or in filters:
    this.UncaughtExceptionHandlers.Add((req, res, operationName, ex) => {
         res.Write($"Error: {ex.GetType().Name}: {ex.Message}");
         res.EndRequest(skipHeaders: true);

The very first callback ServiceStack executes at the start of the pipeline is the RawHttpHandlers, can you try put a debug breakpoint to check if it’s getting called:

RawHttpHandlers.Add(httpReq => {
    Console.WriteLine("In RawHttpHandlers");
    return null;

If not then the Request isn’t being reaching ServiceStack, maybe you have a conflict with your ASP.NET Handler registrations.

The next callback executed before deserializing the request is PreRequestFilters:

PreRequestFilters.Add((req,res) => {
    Console.WriteLine("In PreRequestFilters");

After that the request is deserialized it will execute the GlobalRequestFilters:

GlobalRequestFilters.Insert(0, (req, res, dto) => {
    Console.WriteLine("In GlobalRequestFilters");

Can you let me know how far the request reaches?


The MVC request is ok, We don’t have that favicon file and the exception is normal. If you look above you will see that the exception happen at ServiceStack code: ServiceStack.HttpHandlerFactory.GetHandler.

We do have the Exception Handlers like that but nothing in the log file. I guess after the request reach ServiceStack.HttpHandlerFactory.GetHandler it got the exception and return to client.

I looked into the source code of that Method (ServiceStack.HttpHandlerFactory.GetHandler) and see nothing there write Exception to the log though.

The Exception message says ‘The controller for path… does not implement IController’, this is not a ServiceStack Exception which doesn’t have an IController interface or throw that Exception.

Regardless, please follow all other recommendations in trying to identify the Exception.

sorry I mean this one

It reach ServiceStack right?
Also this happens in our production server and we don’t setup debug there

It looks like there’s a NRE in ServiceStack’s GetHandler() ASP.NET entry point method. This could be the result of invalid initialization.

Can you enable StrictMode to force throwing any Startup Exceptions:

Env.StrictMode = true;

Let me try that.
It’s not always happen and I will update more information when it happen again.

Thank you for your support

I enable strict mode and it turns out that somehow application load the old version ServiceStack dll

“Could not load file or assembly ‘ServiceStack, Version=, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)”

At this time I couldn’t find out why it happen. I will search for that. However it is weird that the application started and there are exception at ServiceStack.HttpHandlerFactory.GetHandler

Thank you for your help

1 Like