Vadim P.
Vadim P.

Reputation: 51

Enable JQuery Intellisense on Visual Studio 2022 ASP.NET Core 6

I have started a new asp.net core 6 (mvc) project on Visual Studio 2022 and added jquery to wwwroot/jquery folder. when typing jquery functions intellisense isn't working. I've tried adding a reference path like on old visual studio versions and it didn't work.

https://i.sstatic.net/2WNN0.png

then tried adding a jsconfig.json file like recommended on some posts that I've found but that also didn't work probably since I'm working offline and it supposed to fetch something from the internet. can anyone help?

Upvotes: 5

Views: 5099

Answers (4)

I had the same issue. If you are in an MVC app with a .Net Framework 4.8.1 the solution that I found was created a file in the Scripts folder Path: Scripts>_references.js, inside of that file put:

/// <reference path="jquery-[version].js" />

Save the file, go to the App_Start folder open the BuldleConfig.cs, and add in the first line:

bundles.Add(new ScriptBundle("~/bundles/App").Include(
  "~/Scripts/_references.js"
));

And register on the web page that you need like this:

@Scripts.Render("~/bundles/app")

Or just include in the first line of your existing bundle the:

"~/Scripts/_references.js"

Upvotes: 0

moein vafapour
moein vafapour

Reputation: 83

i had the same problem. the solution was to put this line of code in my csproj file :

<ItemGroup>
    <Content Include="wwwroot\lib\jquery\dist\jquery.min.js"/>
</ItemGroup>

Upvotes: 0

Ahmed Suror
Ahmed Suror

Reputation: 500

This fixed the problem for me on Visual Studio 2022:

Put this line on the very top of your .js file (of course with the correct jquery path)

///<reference path="Scripts/jquery-3.5.0.js" />

Upvotes: 5

Lee Cichanowicz
Lee Cichanowicz

Reputation: 122

I had a very similar problem. In a project created by a coworker, jQuery Intellisense was not working for me. After weeks of server-side development in the project, I started a front-end development task and found that I had no jQuery Intellisense. All I had to do to revive jQuery Intellisense was to close the solution, delete the .vs folder (hidden) for the solution, then reopen the solution.

Note: Doing this erases your personal "settings" for the solution; for example, which files you had open (tabs), your project-tab color settings, etc.

See step 2 here for the source of this resolution: https://stackoverflow.com/a/61475198/1766253

Upvotes: 1

Related Questions