I am trying to get inline C# to work in my JavaScript files using the MVC Framework. I made this little test code up.
$(document).ready(function() {
ale
Your web server does not process .js files, it only serves them to the client. This is in contrast to .aspx or other ASP.NET file types. These files are interpreted by your server before they are served up to the client.
That inline C# has to be processed by the server in order to make sense. Naturally, it won't work with a just-plain-JavaScript file.
when you have C# code in a separate file and include it in your View the Server does not process the code, the script file will be called by the browser and the inline script would be treated as plain string
alternatively you can try script runat=server when including you script file but I am not sure about the effects of this