A
A
Anton Martsen2014-03-11 12:35:33
JavaScript
Anton Martsen, 2014-03-11 12:35:33

How to connect JS to ASP.NET MVC views?

Colleagues!
Give a recommendation on how best to include third-party JS libraries in ASP.NET view code.
The situation is this: there are a bunch of views, where it is written by hand, for example:

<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>

Now I bring the code up to date and update the dependent components (in this case, it can be seen that the old jquery is used).
As I understand it, you can put all JS connections into a separate PartialView, and then connect it everywhere. Maybe there are some other options?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
wkololo_4ever, 2014-03-11
@wkololo_4ever

And why not write everything you need in _Layout?

E
Eugene, 2014-03-11
@Eugene22

Only it is better not to connect scripts separately. but use bundles , if, of course, you use asp.net mvc 4 and higher.
And so it is necessary to clearly understand why specific scripts are needed and where they may be needed. If everywhere - then _Layout, if not, then it’s better not to overload _Layout sometimes, but to put it in a separate script section

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question