SignalR function not returning objects

Viewed 10

I am new to signalr and I set up a server:

services.AddControllers();

  services.AddSignalR(o =>
  {
    o.EnableDetailedErrors = true;
  }).AddJsonProtocol(options =>
  {
    options.PayloadSerializerOptions.WriteIndented = true;
    options.PayloadSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
    options.PayloadSerializerOptions.Converters.Add(new JsonStringEnumConverter());
  });

And in my hub I have a function that returns an object

public async Task<ResultType> FunctionWithTResult(string path)
{
  // Do work

  return new ResultType { StatusCode = 200 };
}

The problem is that this function is not returning the ResultType. The client only gets an empty object.

I build a client software to test this and it's the same result.

ResultType result = await connection.InvokeAsync<ResultType >("FunctionWithTResult", "test");

Strangely string and int Tasks work just fine. The problem only happens with objects. Does anyone know what I am doing wrong?

0 Answers
Related