0

I have the next line in my javascript file:

"<img alt=\"Active\" src=\"@Url.Content(\"~/Images/play.png\")\" />"

so I tried to do what AHM suggested in this topic (@Url.Content in separate javascript file using ASPNET MVC 3 and Razor):

var ROOT = "@Url.Content(\"~/";
"<img alt=\"Active\" src=\"" + ROOT + "Images/play.png\")\" />"

but I got an error:

Reports/@Url.Content( 404 (Not Found) 

what I did wrong?

any help appreciated!

Community
  • 1
  • 1
Alon Shmiel
  • 6,753
  • 23
  • 90
  • 138

1 Answers1

1

@Url.Content is not supported in JavaScript file

In your code is wrong

var ROOT = "@Url.Content(\"~/"; <= parentheses is not closed & you donot need to escape quotes

Instead use in beginning of file

var ROOT = '@Url.Content("~/")';
haim770
  • 48,394
  • 7
  • 105
  • 133
Satpal
  • 132,252
  • 13
  • 159
  • 168