1
How to make the view
run the javascript file: novo.js
Directory structure:
Views > Product > js > new.js
Error:
View Product.cshtml:
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@section scripts{
@*<script src="@Url.Content("~/Views/Produto/js/novo.js")" type="text/javascript"></script>*@
<script src="~/Views/Produto/js/novo.js"></script>
}
New file.js:
$(function () {
console.log("olá");
});
If you look in the Source tab of your browser devtools the new.js file appears.
– Thales Morais
OK @Thales Morais I will edit the post and improve the question I changed where written see to execute.
– hard123
Okay, I understand your question. The point is that it is necessary to identify whether the file is loading into your browser. Because if it is not there is something wrong in the middleware used for this or something like that. If not the error is on the way to the scipt
– Thales Morais
Important to remember to put middleware in your app.js for the file to identify the static file. I edited my answer to make it clearer
– Thales Morais
@Thales Morais as you can see the example I posted is an execution of a very simple jquery function, the source code is well customized and detail if I put the new.js file in the default folder created by Visual Studio: Content/Scripts works normalment.
– hard123