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

Style sheet not working after upgrade of ASP.NET Core MVC 7.0 application to 8.0 #55383

Open
vsfeedback opened this issue Apr 26, 2024 · 8 comments
Labels
area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update.

Comments

@vsfeedback
Copy link

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


[severity:I'm unable to use this version]
Dear Friends,
I have just tried to upgrade an ASP.NET Core MVC 7.0 application to ASP.NET Core MVC 8.0.
All I have done so far is to change the TargetFramework in the project file from netcoreapp7.0 to netcoreapp8.0 and to update all outdated NuGet packages.
Now my style sheet no longer works. The reference in my Layout file looks like this:

. Could you please tell me what to do to make the stylesheet work again? Thank you for your trouble, and best regards, Eric Weinberger

Original Comments

Feedback Bot on 4/14/2024, 06:48 PM:

(private comment, text removed)

Eric Weinberger on 4/15/2024, 02:12 PM:

(private comment, text removed)


Original Solutions

(no solutions)

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Apr 26, 2024
@dotnet-policy-service dotnet-policy-service bot added the Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. label Apr 26, 2024
@mkArtakMSFT
Copy link
Member

Thanks for contacting us. This is most probably due to incorrect / incomplete migration. Hopefully you can identify the issue yourself once you try to build a minimal repro project for us to investigate. if you do so, we'll look into it to see what may have changed.

@mkArtakMSFT mkArtakMSFT added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Apr 26, 2024
@xenophilios
Copy link

Please forgive me to taking so long to respond.

In my _Layout.cshtml, I had

<link href="~/StyleSheet.css" rel="stylesheet" asp-append-version="true" />

which worked fine in .NET 7.0.

In .NET 8.0 the following seems to work, at least in development:

<environment names="Development"><link href="~/StyleSheet.css" rel="stylesheet" /></environment>
<environment names="Production"><link href="~/StyleSheet.css" rel="stylesheet" asp-append-version="true" /></environment>

I have not yet checked how this affects the effect of edits to the style sheet.

@dotnet-policy-service dotnet-policy-service bot added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. Status: No Recent Activity labels May 3, 2024
@xenophilios
Copy link

I have just experimented with a change in the style sheet, in development. The browser uses the previous version of the style sheet. This is, of course, undesirable.
Could you please advise me on how to avoid this problem without causing others?
Thank you for your trouble.

@xenophilios
Copy link

After I had uploaded the application, the styles did not work.

@javiercn
Copy link
Member

javiercn commented May 7, 2024

@xenophilios thanks for contacting us.

Does it work with "in-private" mode?

@javiercn javiercn added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels May 7, 2024
@xenophilios
Copy link

@javiercn

Thank you for responding so promptly. Could you please elaborate on your question? I'm not sure what it means. Are you referring to a setting in the browser, in Visual Studio, or in my code?

There is, however, some information I could add to what I have supplied so far.

In my _Layout view I have the following:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="expires" content="0" />

In Program.cs, I have the following (plus a lot of other code before, after, and in-between):

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllersWithViews(options =>
{
    options.Filters.Add(

        new ResponseCacheAttribute
       {
           NoStore = true,
           Location = ResponseCacheLocation.None
       });
});

If the instructions in the layout conflict with the instructions in Program.cs, or if either set of instructions is problematic in any way, I would appreciate it if you could let me know.

Thank you very much in advance for your trouble, and best regards,

@xenophilios

@dotnet-policy-service dotnet-policy-service bot added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels May 7, 2024
@mkArtakMSFT
Copy link
Member

@xenophilios the InPrivate mode was the mode of the browser that doesn't store any user preferences. @javiercn suggested that as a test to confirm it's caching what causes this. With Edge (on Windows) you can open the InPrivate mode with Ctrl+Shif+N.

@mkArtakMSFT mkArtakMSFT added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels May 8, 2024
@xenophilios
Copy link

Dear @mkArtakMSFT ,

Thank you for your kind response.

I have run two tests with Edge in InPrivate mode, both on the development server.

If I use asp-append-version="true" with the reference to the style sheet in my layout, the styles are ignored. Without this feature, they work as intended.

The same is true of references to JavaScript files in Razor views. With asp-append-version="true" they are ignored, otherwise they work.

I do not have these problems with .NET 7.0; only with 8.0.

With best regards,
@xenophilios

@dotnet-policy-service dotnet-policy-service bot added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update.
Projects
None yet
Development

No branches or pull requests

4 participants