In my view I have the following code…
<script type="text/javascript">
var url = '@Url.Action("Index", "Home")';
</script>
The problem it emits simply…
<script type="text/javascript">
var url = '/';
</script>
Can someone tell me what is wrong with this?
This is expected, the default routing configuration is configured to use the Home controller and the Index action by default.
See the
RegisterRoutesmethod in yourHttpApplicationtype:If you link to a parameter value which is configured as a default, MVC will avoid rendering it in the output, as it isn’t required.