dotnet / dotnet/aspnetcore

Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation bug with AddRazorRuntimeCompilation() to an ASP.NET Core Web App (MVC) project

Open
#40,066 3 comments 0 reactions 0 assignees View on GitHub
area-mvc feature-runtime-compilation
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

I made a brand new .NET 6 project with VS22, I added Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package (version 6.0.1) from NuGet to the project, then I have added in the Program.cs:

`var builder = WebApplication.CreateBuilder(args); `
`builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();`

and the result is that Bootstrap' layout "crashes": the footer is no more fixed to the bottom of the page, the header doesn't have the shadow anymore and so on. It follows a screenshot of the crashed page:

![Cattura 2](https://user-images.githubusercontent.com/26246313/153009407-61865d05-b25e-40fc-899b-d1d70fd4efa7.PNG)

### Expected Behavior

This is what the page should look like instead:

![Cattura](https://user-images.githubusercontent.com/26246313/153009458-79ba6f4c-7d73-4f66-b41d-53f1dde43548.PNG)

### Steps To Reproduce

Just make a brand new ASP.NET Core Web App (MVC) with .NET 6, with both HTTPS and Docker support:

![Cattura3](https://user-images.githubusercontent.com/26246313/153010568-0a06498b-8b16-4b3e-ad36-9f22482a0f78.PNG)

We now have this:

![Cattura](https://user-images.githubusercontent.com/26246313/153011123-9109120b-df62-4369-9eaa-1c16c7aa458f.PNG)

Then install the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package (version 6.0.1) from NuGet to the project:

![Cattura4](https://user-images.githubusercontent.com/26246313/153010695-1031c6d8-7c6e-4550-8ed1-e0641d959485.PNG)

Finally the command AddRazorRuntimeCompilation();

![Cattura5](https://user-images.githubusercontent.com/26246313/153011071-e561fda0-4647-4bf5-9ea1-52742e6f3502.PNG)

And the result will be:

![Cattura 2](https://user-images.githubusercontent.com/26246313/153011190-78b81820-999d-4458-89ba-338d9535dde2.PNG)

### Exceptions (if any)

_No response_

### .NET Version

.NET 6.0

### Anything else?

ASP.NET Core 6
Visual Studio Professional 2022

Ask me for anything

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.