wwwroot and UseStaticFiles issue after VS upgrade

Julian C. asked on April 17, 2023 19:48

Kentico 13 Core (ver. 13.0.104).

After updating Visual Studio 2022 (ver. 17.5.4) all the links referenced as ~/... (Example: ~/Content/Styles/Site.css) stopped working.

I noticed the same issue on the Dancing Goat site.

The page builder and form builder scripts and styles no longer load (404s). Nothing loads under /Kentico or /_content path: Example: /Kentico/Scripts/builders/builder.css /Kentico/Scripts/builders/page-builder.css /_content/Kentico.Content.Web.Rcl/PageBuilder/Admin/InlineEditors/DropdownEditor/DropdownEditor.css /_content/Kentico.Content.Web.Rcl/PageBuilder/Admin/Selectors/FormComponents/Attachments/attachment-selector.admin.js

I have the app.UseStaticFiles(); added to Startup.cs

I even tried this but no luck: app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = ctx => ctx.Context.Response.Headers.Append(HeaderNames.CacheControl, $"public, max-age={60 * 60 * 24 * 365}"), FileProvider = new PhysicalFileProvider(Path.Combine(Environment.ContentRootPath, @"wwwroot")), RequestPath = new PathString("/wwwroot") });

Correct Answer

Juraj Ondrus answered on April 20, 2023 10:34

I assume you are using .NET 6 - if yes, in this case the VS update causes the defaults of the hosting model to be set "InProcess". Changing this to the "OutOfProcess" should fix the issue. But still, we are looking why the first mentioned is not working after the update.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Julian C. answered on April 20, 2023 21:13

OMFG! Juraj you are a genius!

I changed the hostingModel from "InProcess" to "OutOfProcess" in the web.config and everything works again!

I was struggling with this issue for almost a week!

Thank you Juraj! You're a lifesaver!

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on April 21, 2023 05:14

Well, I was scratching my head hard too. In fact, it was one of our QA engineers who noticed this! So the credits should go there :-) I am just the messenger!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.