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

Css isolation not working with Razor runtime compilation #33446

Closed
vsfeedback opened this issue Jun 10, 2021 · 3 comments
Closed

Css isolation not working with Razor runtime compilation #33446

vsfeedback opened this issue Jun 10, 2021 · 3 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-css-isolation This issue is related to CSS Isolation feature feature-runtime-compilation
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


Although the official MS documentation mentions only CSS isolation support for Blazor, I have found several independent articles (e.g. here), demonstrating that it can be used also in ASP.NET Core MVC/Razor Pages applications.

Is it officially supported? Because I have come across a major stumbling block:

If I enable Razor runtime compilation in my app, when I run it (either from VS 2019 or from the CLI with dotnet run), it opens in the browser with all the isolated css applied correctly.
But when I edit and save any of the source files, which triggers a recompilation, then refresh the browser, the css disappears, and inspecting the page in the browser shows that the reason for this is that the unique attributes that were added to all the elements in the initial build were stripped.

Steps to reproduce the problem:

  1. In VS 2019, create a new "ASP.NET Core Web App" project. In the Additional Information dialog, check the Enable Razor runtime compilation checkbox.
  2. Add a new empty file to the Pages folder, named "Index.cshtml.css". Place any applicable styles in it, e.g.
p {
  font-size: 30px;
  color: blue;
}
  1. Run the app. The above style is applied.
  2. Make any change to Index.cshtml (e.g. add some plain text) and save.
  3. Refesh the browser. The updated page is displayed without the above css applied.

.
This is the behavior when the app's target framework is .Net 5.0.
When using .Net 6.0 Preview it's even worse - even on the initial display of the page (step 3 above), the elements don't have the unique attributes and the css isn't applied.


Original Comments

Feedback Bot on 6/1/2021, 07:05 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Feedback Bot on 6/1/2021, 11:06 PM:

Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem?view=vs-2019#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.


Original Solutions

(no solutions)

@ghost ghost added the Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. label Jun 10, 2021
@mkArtakMSFT mkArtakMSFT added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-css-isolation This issue is related to CSS Isolation feature feature-runtime-compilation labels Jun 10, 2021
@javiercn
Copy link
Member

Thanks for contacting us.

This is not a core scenario we are planning to support with CSS isolation unless we receive more feedback from other customers about it. CSS isolation is a build time process and by definition runtime compilation is not part of it.

@pranavkm we could potentially make this work to a degree if we "burn" the CSS scope into the assembly metadata and "rehydrate" it on the compiler. It would obviously not allow you to change the CSS file, but it would at least make sure the scope we generated at build is "re-applied" during runtime compilation.

@javiercn javiercn added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Jun 14, 2021
@javiercn javiercn added this to the Backlog milestone Jun 14, 2021
@ghost
Copy link

ghost commented Jun 14, 2021

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@TanayParikh
Copy link
Contributor

Thanks for contacting us. We're closing this issue as there was no community involvement here for quite a while now.

You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.

@dotnet dotnet locked as resolved and limited conversation to collaborators Nov 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-css-isolation This issue is related to CSS Isolation feature feature-runtime-compilation
Projects
None yet
Development

No branches or pull requests

4 participants