ASP.Net intellisense incorrectly offers web road for paths

Following the Pluralsight course, I am coding an ASP.NET 5 / MVC 6 web application due to an effective scratch. When referencing an object in the format, for example:

~/js/site.js 

or

 ~/css/site.css 

in the .cshtml file, Intellisense shows an error stating that the files could not be found, assuming the paths should be:

 ~/wwwroot/js/site.js ~/wwwroot/css/site.css 

However, using the first group of paths correctly refers to files on the actual web page, but uses the second group of paths, since Visual Studio offers to break the web page and js and css are not loading.

Elements are located under the wwwroot folder, as you can see here:

Solution Browser

Why does Intellisense behave this way and how can I fix this behavior?

Edit: Here is the project.json file:

 { "version": "1.0.0-*", "compilationOptions": { "emitEntryPoint": true }, "dependencies": { "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final", "Microsoft.AspNet.Mvc": "6.0.0-rc1-final", "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final", "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final" }, "commands": { "web": "Microsoft.AspNet.Server.Kestrel" }, "frameworks": { "dnx451": { }, "dnxcore50": { } }, "exclude": [ "wwwroot", "node_modules" ], "publishExclude": [ "**.user", "**.vspscc" ] } 
+5
source share
1 answer

In order for your intellisense to refer to your files under wwwroot without errors, your project.json file should have the following:

"webroot": "wwwroot",

This should solve your problem. This minor issue is a known bug in MS when creating a new MVC project using scaffolding in Visual Studio 2015. I think it was resolved with 6.0.0-rc 1-final.

+1
source

Source: https://habr.com/ru/post/1237800/


All Articles