I am trying to place my javascript files with my views.
I have the following js file location. /Views/Home/Home.js
However, when referenced with a script tag, it results in a 404 error.
As per the following SO question: ASP.NET MVC - Where do you put your .js files if you dont want to store them in /Scripts?
I added file.js to my Register routes. (Did not resolve the problem)
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{file}.js");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
}
How can i store and reference my js files next to my views?
See Question&Answers more detail:os