Closed oyvindwh closed 3 years ago
Stacktrace:
fail: Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer[2]
Connection ID "17077649797189468231", Request ID "80000048-0002-ed00-b63f-84710c7967bb": An unhandled exception was thrown by the application.
System.InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
at Microsoft.AspNetCore.Server.IIS.Core.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at Microsoft.AspNetCore.Server.IIS.Core.WrappingStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Compression.DeflateStream.WriteDeflaterOutput()
at System.IO.Compression.DeflateStream.WriteCore(ReadOnlySpan1 buffer) at System.IO.Compression.DeflateStream.Write(Byte[] array, Int32 offset, Int32 count) at System.IO.Compression.GZipStream.Write(Byte[] array, Int32 offset, Int32 count) at WebMarkupMin.AspNetCore5.BodyWrapperStreamBase.Write(Byte[] buffer, Int32 offset, Int32 count) at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionBody.Write(Byte[] buffer, Int32 offset, Int32 count) at Microsoft.AspNetCore.WebUtilities.HttpResponseStreamWriter.Write(String value) at Newtonsoft.Json.Utilities.JavaScriptUtils.WriteEscapedJavaScriptString(TextWriter writer, String s, Char delimiter, Boolean appendDelimiters, Boolean[] charEscapeFlags, StringEscapeHandling stringEscapeHandling, IArrayPool
1 bufferPool, Char[]& writeBuffer)
at Newtonsoft.Json.JsonTextWriter.WriteEscapedString(String value, Boolean quote)
at Newtonsoft.Json.JsonTextWriter.WritePropertyName(String name, Boolean escape)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeDictionary(JsonWriter writer, IDictionary values, JsonDictionaryContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at EPiServer.Formatters.Internal.ExtendedNewtonsoftJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, ResponseDecorator responseDecorator)
at EPiServer.Formatters.Internal.ExtendedNewtonsoftJsonOutputFormatter.WriteAsync(OutputFormatterWriteContext context, ResponseDecorator responseDecorator)
at EPiServer.Shell.Services.Rest.RestResultBase.ExecuteResultAsync(ActionContext context)
at EPiServer.Shell.Services.Rest.RestResult.ExecuteResultAsync(ActionContext context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.
Reported in our internal tracker.
Microsoft fixed it as part of aspnetcore6 https://github.com/dotnet/aspnetcore/commit/0b8a066f58d63e6a8a37b073c308b30b2a60cd49
in aspnetcore5 they only allowed to control the Input threshhold: https://github.com/dotnet/aspnetcore/blob/v5.0.9/src/Mvc/Mvc.NewtonsoftJson/src/MvcNewtonsoftJsonOptions.cs#L50
in aspnetcore6 we can also control the output: https://github.com/dotnet/aspnetcore/blob/v6.0.0-preview.7.21378.6/src/Mvc/Mvc.NewtonsoftJson/src/MvcNewtonsoftJsonOptions.cs#L70
For now (until we are on aspnetcore5) customers that use newtonsoft will have to use this workaround for our stores:
var uiOptions = context.RequestServices.GetService<UIOptions>();
var resolver = context.RequestServices.GetService<IVirtualPathResolver>();
var syncIoFeature = context.Features.Get<IHttpBodyControlFeature>();
app.Use(async (context, next) =>
{
var uiEditUrl = resolver.ToAbsolute(uiOptions.EditUrl.ToString()).TrimEnd('/');
if (context.Request.Path.StartsWithSegments(uiEditUrl, StringComparison.OrdinalIgnoreCase))
{
if (syncIoFeature != null)
{
syncIoFeature.AllowSynchronousIO = true;
}
}
await next();
});
Sub pages contains both Arabic and Chinese translated pages.
@barteksekula, can be seen in the integration environment. More details can be shared in Teams.
@lunchin