In ASP.NET MVC, you can run @Url.Content
on views and controllers.
This variable returns the relative level the site is in.
My question is: how to run Url.Content
via JavaScript? Is there any way in MVC?
EDITED
Example of @Url.Content
in C #
<img src="@Url.Content("~/Content/img/teste.jpg")" />
Ambient result
| DEV | /Content/img/teste.jpg" | | PRD | /NovoSite/Content/img/teste.jpg" |
In my case, the production environment is inside a "NovoSite" folder, using @Url.Content
I do not need to worry about this.
But if I do something with javascript / jquery example
$("#element").html('<img src="/Content/img/teste.jpg" />');
It will only work in my Dev environment, and I need to change the path every time I do a deploy