0

How can I write some value inside a separate JS file?

just an example:

// this is my file.js
var url = @Url.Action("foo");
var x = @Model.X
var y = @varY

If this is not possible what workaround can i take?

Fabricio
  • 7,705
  • 9
  • 52
  • 87
  • Use functions and call them from razor page. Because this is not possible. This property is available for Razor Engine... – AliRıza Adıyahşi Jul 02 '13 at 15:23
  • 1
    No, you should pass this variables from view. [Read more here](http://stackoverflow.com/questions/17394880/getting-rid-of-hardcoded-strings-in-javascript-with-asp-net-mvc/17396877#17396877) – YD1m Jul 02 '13 at 15:24

0 Answers0