MVC3 Url.Action querystring generation

前端 未结 2 1869
心在旅途
心在旅途 2020-12-08 06:30

I am trying to generate an url for an MVC 3 action within javascript environment (in a cshtml file).



        
相关标签:
2条回答
  • 2020-12-08 07:02
    <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>
    
    0 讨论(0)
  • 2020-12-08 07:07
    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!

    0 讨论(0)
提交回复
热议问题