Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: html content is empty when edit in a child site #4017

Closed
zyhfish opened this issue Mar 19, 2024 · 5 comments
Closed

Bug: html content is empty when edit in a child site #4017

zyhfish opened this issue Mar 19, 2024 · 5 comments

Comments

@zyhfish
Copy link
Contributor

zyhfish commented Mar 19, 2024

Reproduce Steps

  1. fresh install the instance with default settings;
  2. create a new child site in site management, with the domain set to {domain}/child;
  3. browse to the child site home page, click the edit button.
  4. click the edit button for any html module, you will open the edit content popup.

Expected Result
the html content should display in the editor.

Actually Result
both the rich-text editor and raw editor are empty.
image

@sbwalker
Copy link
Member

sbwalker commented Mar 19, 2024

This one is a complicated issue...

When running on the Server, the component initially makes a call to the HtmlTextService to get the most recent HtmlText object based on the ModuleId. This works fine and returns the correct record.

Then Blazor makes another call to the HtmlTextService, and this time the SiteState.Alias is null - so it tries to resolve the correct Alias for the HttpContext, however the HttpContext is:

GET http://localhost:44357/_blazor HTTP/1.1 101 Switching Protocols

And because the Url is missing the "child" alias path it resolves the Alias to the root domain. And since ModuleId does not belong to the root domain SiteId, it returns an HtmlText object of null. Which is why the RichTextEditor displays no content.

I believe the problem is that the second call to the HtmlTextService is transitioning render mode boundaries - ie. from Static to Interactive, as the Edit.razor component is an Interactive component. For some reason the SiteState is not being passed across the render mode boundary - which means the "context" is lost.

Note that this is not a problem when using the API approach for data access because the Controller always has the correct Url with the child alias path embedded in it, so it can resolve the Alias correctly. It is also not a problem for root domains because the GET request for _blazor includes the full domain name which can be resolved to an Alias.

So this is only an issue for child sites. And it only became an issue after the "dual" service HtmlTextService was added, because previously all data access occurred through the API Controller.

@thabaum
Copy link
Contributor

thabaum commented Mar 19, 2024

@sbwalker what I notice is the extra / as well.

image

image

The above only happens on the homepage.

I forced the edit component into static and the raw data did exist although the rich editor was broken along with interactivity. So there is definitely an issue with crossing render mode boundaries.

sbwalker added a commit that referenced this issue Mar 19, 2024
fix #4017 - SiteState being lost in server rendered scenarios
@sbwalker
Copy link
Member

sbwalker commented Mar 19, 2024

#4019 fixes the issue. The problem is that there were actually 2 SiteState services registered in the framework - one was defined in the Shared project, and one was defined in the Server project (Infrastructure namespace). The reason why there were 2 is because there were some properties on the SiteState class which were only applicable to Client projects - and these were only included in the Shared version of the class. However now that Blazor is statically rendered server-side, it blurs the lines between client and server components - so it makes sense to only have a single SiteState definition and service. So the fix was to remove the SiteState class from Server/Infrastructure - which allows the framework to marshal the SiteState values properly across the render mode boundary.

Thank you @zyhfish for discovering this issue, as it affected the multi-tenancy capability which is one of the core features of Oqtane.

@sbwalker
Copy link
Member

@thabaum I think you are identifying a different issue - not related to the issue which @zyhfish reported. The Url issue is most likely related to the refactoring of NavigateUrl(). It should be logged separately but I will investigate further.

@thabaum
Copy link
Contributor

thabaum commented Mar 19, 2024

@sbwalker Nice to see this was resolved and not as huge of an issue as first thought. I made the modifications to source and tested working as expected.

I will report the new issue found as I was wondering if it was an issue worth reporting while reviewing this, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants