在通过服务堆栈发送的最终消息等待下一次发送心跳之前,我们遇到了问题。我们认为它类似于:
Servicestack server sent events
但是,现在不建议使用res.Write(),而res.WriteAsync()会抛出:
System.InvalidOperationException: This operation cannot be performed after the response has been submitted
我还尝试通过使用
解决上述线程中所述的问题:// Remove url compression https://stackoverflow.com/questions/53559038/asp-net-core-disable-response-decompression
// because of https://stackoverflow.com/questions/25960723/servicestack-server-sent-events
services.AddResponseCompression(options =>
{
var gzip = options.Providers.OfType<GzipCompressionProvider>().FirstOrDefault();
if (gzip != null)
{
options.Providers.Remove(gzip);
}
});
感谢朝正确的方向努力解决此问题,因为当前接受的解决方案已不再可行。