簡體   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