1

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

enter image description here

Community
  • 1
  • 1
Jawahar05
  • 354
  • 8
  • 17

1 Answers1

1

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+.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • 1. Then How to include a bootstrap and j query files in the application 2.I'ts used minifing the bootstrap file while using the npm (of course I'm used npm) 3.While removing All it throwing a numerous no of errors. – Jawahar05 Jul 05 '18 at 13:02
  • 1. Again, either libman or npm. Personally, I'd go with npm. Libman is still feels pretty alpha. 2. Bundling/minifying is either achieved via bundleconfig.json or using something like grunt/gulp/webpack. If you go the npm route, you should use grunt/gulp/webpack. 3. `All` is a superset of the `App` metapackage. You might have dependencies on some of the packages `All` includes that aren't part of `App`. However, Microsoft recommends adding such dependencies manually instead of depending on `All`. – Chris Pratt Jul 05 '18 at 13:18
  • "https://stackoverflow.com/questions/48481003/how-to-use-bootstrap-4-in-asp-net-core" View this link BuildBundlerMinifier explained. – Jawahar05 Jul 06 '18 at 13:45
  • You don't need that extension for bundleconfig.json support. It's built-in: https://learn.microsoft.com/en-us/aspnet/core/client-side/bundling-and-minification?view=aspnetcore-2.1&tabs=visual-studio%2Caspnetcore2x – Chris Pratt Jul 06 '18 at 13:54