Closed stevenvolckaert closed 2 years ago
There are a few possibilities here. The main one that springs to mind is if you have the LSP Razor editor enabled. There is an upcoming workaround to ensure you are using the 'legacy' editor which supports ASP.NET 4.x - https://github.com/dotnet/razor-tooling/pull/5781
For now, you can go to Options -> Text Editor -> HTML -> Advanced and select "Use legacy Razor editor for ASP.NET Core" in VS2022.
In VS2019 make sure you don't have the option set to use the new editor in Options -> Preview Features.
The other thing to check is your web.config
file has the appropriate includes and binding redirects for MVC, Razor etc. (check the example project for settings.)
There is a feature to overwrite the web.config
with the correct binding redirects (per the comment in your project file).
https://czemacleod.github.io/MSBuild.SDK.SystemWeb/Binding_Redirects/Autogenerating-Binding-Redirects.html
Thanks for these suggestions @CZEMacLeod, I'll try them out in the morning and report back here.
Have a great day!
Setting Use legacy Razor editor for ASP.NET Core (requires restart) to True
helped, thank you @CZEMacLeod!
I guess on the next Visual Studio release, I could test if the LSP Razor editor is included. If I understood correctly, I could then revert Use legacy Razor editor for ASP.NET Core (requires restart) back to its original setting False
?
@stevenvolckaert With the new detection code, it should simply be a case of adding
<ItemGroup>
<ProjectCapability Include="LegacyRazorEditor" />
</ItemGroup>
to your project (or to the MSBuild.SDK.SystemWeb
itself which is the plan, but I will wait for the release of the tooling and test before updating the SDK). Note - if you use ASP.NET 4.x Razor files in a class library (like with RazorGenerator/RazorGenerator) then you will probably need to add the ProjectCapability
manually to those projects too.
@CZEMacLeod OK, thank you again for your help! Much appreciated!
Hello!
We're using
MSBuild.SDK.SystemWeb
v4.0.49` in some of our ASP.NET MVC 5 projects, which are targeting .NET Framework 4.8,My development team has let me know that when they open CSHTML files, they get IntelliSense errors like the one below.
I tried updating
MSBuild.SDK.SystemWeb
to the latest release (v4.0.63
), but no luck. When running or debugging the application, there is no problem at all; everything seems to work.Would anyone have some ideas on how to fix or workaround this?
In both VS 2019 and VS 2022, the default editor for CSHTML files is HTML Editor:
Also, when I open a CSHTML file, the following notification is displayed in the bottom-left corner of the screen:
And when I click the notfiication,Visual Studio takes me to the Language Client activation failures; exception details below:
You can find the
csproj
of one of the projects below: