简体   繁体   中英

ASP.Net Core MVC missing assembly reference

I try to do an login page in Visual Studio 2017 using MVC Empty template. The database connection, the migration and front end code with bootstrap has been done successfully and necessary configuration files and NuGet packages also installed/updated, While I run this application I'm facing this error lines as internal server error

One or more compilation references are missing. Ensure that your project is referencing 'Microsoft.NET.Sdk.Web' and the 'PreserveCompilationContext' property is not set to false.

The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)

and the added NuGetPackages are

  1. Bootstrap
  2. BuildBundlerMinifier
  3. Microsoft.AspNetCore.All
  4. Microsoft.VisualStudio.Web.CodeGeneration.Design
  5. Microsoft.AspNetCore.App

在此处输入图片说明

There's some issues with your NuGet packages.

  1. There is no Bootstrap NuGet package for ASP.NET Core. That's only for ASP.NET MVC. I doubt there's any framework dependencies here, but it's a bad idea to use it regardless. For libraries, you should either be using the built-in library manager (libman) or npm with grunt/gulp/webpack.

  2. No idea what BuildBundlerMinifier is, but you likely don't need that either. If it's a hook into creating build tasks (as it's name indicates), it's possible this could cause issues.

  3. You should not have references to both Microsoft.AspNetCore.All and Microsoft.AspNetCore.App . The current recommendation is to use App .

  4. Depending on your version of ASP.NET Core, Microsoft.VisualStudio.Web.CodeGeneration.Design could cause problems. Specifically, this reference will break your app if you're targeting Core 2.1+.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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