I am trying to host an enterprise standard where all page-level javascript is contained in an external file and not included in an ASPX or ASCX file. Using ASP.NET MVC 2, I am wondering how I can reference the script file (.js) regarding the view.
In other words, I don't want to change my Scripts folder with all the small .js files that will exist in the application. From an organizational point of view, using a .js file with a .aspx / .ascx file makes the most sense. For example, if I have a controller named "MyController" with the action "MyAction", I will have the file MyAction.aspx in the Views / MyController folder and you want to place the script file named "MyAction.js" in the same folder. However, I cannot use:
<script src="MyAction.js" type="text/javascript"></script>
and it doesn't seem to work either:
<script src="<%= Url.Content("~/Views/MyController/MyAction.js") %>"
type="text/javascript"></script>
So, I assume that the problem may be related to the routing table, but I'm still a newbie to MVC, so I'm not sure.
Second question: is it possible to embed javascript as a resource, as we can, using traditional ASP.NET and generate a non-human-readable URL on our client page?
UPDATE
, , . , . , , , , .