繁体   English   中英

VS 2019 - ASP.NET Core MVC web 应用程序(用 C# 编写):全新项目出现多个错误

[英]VS 2019 - ASP.NET Core MVC web app (written in C#) : multiple errors on brand new project

使用 ASP.NET Core 5.0 MVC 的全新项目,编写于 C#。

查看任何 default.cshtml 页面时,错误列表 window 中出现多个错误。

但是,该项目仍然可以正常构建和运行。

错误包括:

- The name 'ViewData' does not exist in the current context.
- The name 'RenderBody' does not exist in the current context.
- The name 'await' does not exist in the current context.
- The name 'Context' does not exist in the current context.
- The namespace "ASP" already contains a definition for '_Page_Default_cshtml' 

(完整列表https://pastebin.com/YM5JnqBj

可能是你安装VS 2019时没有选择ASP.NET和.NET跨平台开发,只选择了其他环境进行开发。 我在没有安装正确模块的情况下创建了 ASP.NET 项目。 注意到这一点后,我回去安装了缺少的两个模块,但这并没有解决问题。 VS 2019后端有些链接没有建立。

最终的解决方案——从一开始就用正确的模块重新安装 VS 2019(不要先尝试修复它)。 现在所有助手,代码完整,Intellicode,一切正常。

错误: 在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM