We'd like to split out the javascript from our Razor views (so we can test). Can we locate the .js files near the views they correspond with rather then in the Scripts folder? For example, we'd like to see this in solution explorer:
MyMvcProject
- Views
- Home
- About.cshtml
- About.js
However, I don't know to references the .js file from the .cshtml view.
For security reasons, asp.net-mvc blocks all file access to the /Views folder from URL's. This can be worked around, but I would suggest NOT doing this for security reasons.
You should generally leave your scripts in Scripts folder, particularly the system-wide ones such as jquery and the unobtrusive stuff. This is so they can be more easily updated through NuGet as new versions or bugfixes are released.
I'm not sure why you have a problem with testing and leaving them in the default location.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With