The default WebMatrix site template doesn’t include jQuery and since I’ve been doing a lot of jQuery content lately I thought it would be good to demonstrate the best way to include jQuery (as well as jQueryUI and any number of other libraries and resources you might use).
Start by launching WebMatrix and creating a a new web site using the Starter Site template.
Then run the site that you just created using the “Run” button in the WebMatrix IDE.
When you run the Default.cshtml page will be displayed. Note that the site is running on http://localhost and a dynamically assigned port number.
Replace Default.cshtml with “_Admin” and you will be redirected to this page.
This is a one-time-only security feature. You need to create a password file.
Enter the password of your choice (twice) and click “Create Password”.
On the next page READ the instructions.
They tell you that you need to rename a newly created file in your project.
In App_Data there is a newly created folder named “Admin”. If you don’t see it you may need to refresh the directory tree by right clicking on the root folder name and selecting the refresh option.
Delete the leading underscore from the “_Password.config” file and then go back to the browser that is running your website.
Enter the password you used in the previous step and click “Login”.
Now we can start to work with the package manager.
By default, the package manager sows “”Installed” packages. Since we haven’t installed any yet, this is not very exciting.
In the “Show” dropdown change the value to “Online”.
After the page refreshes change the “Source” dropdown to “Default (All)”
Then enter “jQuery” (or any term you want to search packages for) and click the “Search” button.
This will return ALL the results that contain the search term. In our case we want the latest version of jQuery which doesn’t appear in the results list until the second page.
Use the page number links at the bottom of the result set to navigate to the second page, select the latest version of jQuery (1.5.1 at the time of this writing) and click “Install”.
Then review the package details and click “Install”.
Confirm that the package manager finished successfully.
Then switch back to the WebMatrix Tool (o can close the browser if you’re done installing packages.)
Refresh your folder tree as described above and you will see the 1.5.1 versions of jQuery and jQuery.min installed in a folder named “Scripts”.
jQuery is now installed and ready for your use.
Don’t forget to explore the available packages – you’ll be surprised at what you find.