![](/img/trans.png)
[英]ASP.NET MVC - How do I Call a Controller Method from within a View to Redirect to Multiple Other Views?
[英]ASP.net MVC - Call other controller from view
嘗試從“交易”控制器中的視圖調用,另一個“信用卡”控制器中的視圖調用:
@(Url.Action("ShowImage", "CreditCard"))/" + ConcatString
來自IMG標簽的src屬性。 但由於來自其他控制器,因此該網址無效。 插入的:
/creditcard/showimage/45809014157220320
它的:
/Transaction/TransactionToPDF/creditcard/showimage/45809014157220320
大膽的猜測,您的操作是否不為圖像ID接受null
? 與其嘗試添加concatstring
嘗試指定參數,例如,
@Url.Action("ShowImage", "CreditCard", new { ImageId= ConcatString })
同樣,根據操作允許的參數是什么,應該讓路由系統解析正確的URL。
當然,您可以使用Html.Action幫助器。 但是,對我來說,這樣做比較容易。
<img src="/CreditCard/ShowImage/@ConcatString" class="img float-xs-right" width="350" height="380" id="creditCardImage" />
我認為您遇到了“區域”問題。 如果它們在不同的區域,則應該可以執行以下操作:
@(Url.Action("ShowImage", "CreditCard", new { area = "" }))/" + ConcatString
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.