I have an existing ASP.NET core 2.2 (SDK version 2.2.108) Web API and I'm now adding MVC to host a web page with a controller. I've added:
- the new controller
- the new .cshtml view
- made sure my startup.cs contains services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
I'm using Http.Sys and I get 500 [Microsoft.AspNetCore.Server.HttpSys.MessagePump] ProcessRequestAsync. If I enable exceptions in VS 2017 (15.9.13) I see:
Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException: 'One or more compilation failures occurred:
310z1p4f.mzl(4,41): error CS0234: The type or namespace name 'Razor' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
310z1p4f.mzl(5,40): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
310z1p4f.mzl(4,82): error CS0518: Predefined type 'System.Type' is not defined or imported
310z1p4f.mzl(4,122): error CS0518: Predefined type 'System.String' is not defined or imported
and it continues.
I see in the build output:
Microsoft.AspNetCore.Razor.dll
Microsoft.AspNetCore.Razor.Language.dll
Microsoft.AspNetCore.Razor.Runtime.dll
I followed several different discussions on SO and github:
- https://stackoverflow.com/a/51908353/5048049
- https://github.com/dotnet/standard/issues/542
- The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
- The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor'
- https://github.com/aspnet/AspNetCore.Docs/issues/8880
but no luck. Ideas?