I wonder why my js file work when I call it in the view:
@section Scripts {
You should Add rendersection to your Layout Page which your view using.
@RenderSection("scripts", required: false)