I'm working on an ASP.net MVC application. One thing that I really like about ASP.net MVC is the way that it allows you to refer to relative paths in server-side code. I was wondering if there is some standardized way of doing this in client-side code.
I have a way of doing this. I write the following in my layout page.
<script type="text/javascript">
var ApplicationPath = '@Url.Content("~/")';
</script>
Making this the first script in my layout page, I can refer to relative paths from any .js file using the ApplicationPath
variable. This seems to work well, but I'm left wondering if there is some built-in way of working with relative paths in JavaScript. This works well for me, but someone else might use a different convention.
Does ASP.net MVC 4 have some standardized way of referring to relative paths in JavaScript?