Deserialization issue using .net core 3.1

I am building a new service targeting core 3.1
I am re-using a piece of code from another service that was targeting 2.1 which is working perfectly well:

//var gasPath = string.Format(“api/gases/{0}”, gasId);
var gasPath = string.Format(gasPathTemplate, gasId);
using (var client = new JsonServiceClient(storageLacunaBaseUri))
{
//var test = client.Get(gasPath);
return client.Get(gasPath);
}

However in the new service I get a deserialization error (Type definitions should start with a ‘{’, expecting serialized type) when the GasDefinition has not changed!

Type definitions should start with a ‘{’, expecting serialized type ‘GasDefinition’, got string starting with: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tran

The service queried is also built using ServiceStack and targetting 2.1 so 2.1 <=> 2.1 works but not 3.1 <=> 2.1.

I can see text serialization for JSON (NewtonSoft.Json / System.Text.Json) is one of the change between 2.1 and 3.1 but I cannot work out what setting I must apply to get my new service to deserialize properly. Please could you help?

The Service is returning a HTML page, either the request is malformed or there’s no such Service or the remote Service is returning a HTML error page. Can you provide the full HTTP Request/Response Headers to see what the actual request that’s being sent is?

Note: You don’t need to dispose Service Clients as it’s a NOOP

The remote service is running and responding well but never receives the request.

I have deserialized the response I get using:

            var gasPath = string.Format(gasPathTemplate, gasId);
            using (var client = new JsonServiceClient(storageLacunaBaseUri))
            {
                using (System.Net.HttpWebResponse webRes = client.Get(storageLacunaBaseUri + gasPath))
                {
                    var headers = webRes.Headers;
                    var json = webRes.GetResponseStream().ReadFully().FromUtf8Bytes();
                    webRes.Close();
                }
                //var test = client.Get<GasDefinition>(storageLacunaBaseUri + gasPath);
                return client.Get<GasDefinition>(gasPath);
            }

The response is an HTML page redirecting me to my company security proxy server which should anyway be bypassed for local addresses which are used for all the services. Below is the value of headers:

{Server: BarracudaHTTP, 4.0
Date: Fri, 21 Aug 2020 11:30:00 GMT
Cache-Control: no-store, no-cache, max-age=0
Pragma: no-cache
X-Cache: MISS from barracuda1.xxxxxxxxxxx.net
Transfer-Encoding: chunked
Connection: keep-alive
Content-Type: text/html; charset=UTF-8

}

I don’t know what BarracudaHTTP is but if your Request isn’t getting received then I’m assuming your middleware proxy is interfering/blocking it, which isn’t going to be anything you can change in ServiceStack to resolve.

If you want to see what’s happening you’d need to see the full initial raw HTTP Request & Response Headers. I can’t tell what this is, whether it’s the initial response or the result a redirect, I can only infer that it’s not a response from ServiceStack.

Try using a HTTP Packet sniffer like Fiddler in order to see the initial HTTP Request & Response, see how to configure it in .NET Apps with: https://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/ConfigureDotNETApp