I am trying to generate an url for an MVC 3 action within javascript environment (in a cshtml file).
<script type="text/javascript">
var src = "@Html.Raw(Url.Action("GetProductImage", new { productId = Model.Product.Id, pos = 1, size = 0 }))";
$(document.createElement("img")).attr("src", src);
</script>
var src = "@Html.Raw(Url.Action("GetProductImage", new { productId = Model.Product.Id, pos = 1, size = 0 }))";
Url.Action worked for me not HtmlUrl.Action
Enjoy!