Using Inline C# inside Javascript File in MVC Framework

后端 未结 9 1750
野性不改
野性不改 2020-12-31 07:39

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         


        
9条回答
  •  Happy的楠姐
    2020-12-31 08:16

    As others have said, the C# is not being processed by the server.

    A possible solution would be to have a separate view that uses the same model and outputs the JavaScript, then reference that view in your .

    Added as per SLaks' answer:

    Set the content-type to text/javascript, and put your JavaScript source directly below the <%@ Page directive (without a

提交回复
热议问题