OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.37k stars 2.38k forks source link

Response Compression causes content encoding error on tenants #11295

Closed DemeSzabolcs closed 2 years ago

DemeSzabolcs commented 2 years ago

Describe the bug

Enabling Response Compression on a different tenant other than the Default one causes content encoding error on that tenant's homepage.

To Reproduce

Steps to reproduce the behavior:

  1. Go to Dashboard -> Configuration -> Tenants
  2. Click on Add Tenant and create a new tenant.
  3. Setup the newly created tenant (let's call it example tenant).
  4. Go to the example tenant's Dashboard -> Configuration -> Features and enable Response Compression.
  5. Go to the example tenant's homepage (~/exampleTenant). OR go back to the default tenant's Dashboard -> Configuration -> Tenants and click on the example tenant's View button.
  6. See that the page doesn't load, and there is a content encoding error.

Expected behavior

Tenants should not have content encoding errors on the homepage after enabling Response Compression.

Skrypt commented 2 years ago

I can't reproduce locally on my PC.

https://user-images.githubusercontent.com/3228637/156813275-f728c8a6-56be-4db6-ad45-d6f7e7b33087.mp4

Is there more to it? Domain names usage?

DemeSzabolcs commented 2 years ago

That's strange. I used the Software as a Service recipe, but I was able to reproduce the error with the Blog recipe too.

I'm sure that this is a bug because I was able to reproduce it on a completely different PC.

hishamco commented 2 years ago

Could you please share a GIF screenshot?

Skrypt commented 2 years ago

There's pretty much nothing in that ResponseCompression module either than we enable the ASP.Net middleware.

hishamco commented 2 years ago

You are right, may be there's a caching issue

DemeSzabolcs commented 2 years ago

response compression

Sometimes it doesn't give a content encoding error, instead displays random characters, as you can see in the gif. I reproduced this after cleaning browser caches and cookies (Chrome and Firefox) and on a different computer.

jtkech commented 2 years ago

I could repro ;)

Encoding issue

jtkech commented 2 years ago

And if in place of /tenant1 I add an ending slash /tenant1/ it works

jtkech commented 2 years ago

And seems to work if I run the app from the command line not from Visual Studio

 bin/debug/net5.0/orchardcore.cms.web.exe
jtkech commented 2 years ago

Maybe related https://github.com/dotnet/aspnetcore/issues/32767#issuecomment-842691720

jtkech commented 2 years ago

So seems to be related to the hot reload feature under VStudio, after doing the following as commented here https://github.com/dotnet/aspnetcore/issues/32767#issuecomment-975583962 it was working.

Can confirm that the injection of the scripts for the hot reloading feature is what triggers this. Had to rip it out completely to get a working solution back. I.e. go specifically into Tools -> Options -> Debugging ->.NET / C++ Hot reload and disable all the server-side C# hot reloading features altogether in addition to everything hot-reloading related under Tools -> Options -> Projects & Solutions -> ASP.NET Core.

Added a comment to follow https://github.com/dotnet/aspnetcore/issues/32767#issuecomment-1059680740

Skrypt commented 2 years ago

I'm using Visual Studio 2022 17.1.0 and I can't repro this when debugging with IISExpress and Hot Reload enabled. Will try different things and report here.

I get the same result when debugging in Visual Studio 2022 with Kestrel.

jtkech commented 2 years ago

I'm using Version 17.0.5, will try to upgrade tomorrow ;)

hishamco commented 2 years ago

Me too when I'm using the first version of 2022 I'm facing some issues while running the app ;) but may be the issue related to an ASP.NET Core issue as @jtkech mentioned above

jtkech commented 2 years ago

So in my case was caused by enabling Projects and Solutions > ASP.NET Core > CSS Hot Reload

Upgrading to Visual Studio 2022 17.1.0 fixed the issue

hishamco commented 2 years ago

So can we close this if it's VS related? We could document this because one may spent many hours on issues that related to VS

DemeSzabolcs commented 2 years ago

Yes, what @jtkech said, solved it. Thanks!

jtkech commented 2 years ago

Okay cool, thanks for confirming