[英]ASP.net MVC - Call other controller from view
try to call from view in "Transaction" controller, The other "CreditCard" controller: 尝试从“交易”控制器中的视图调用,另一个“信用卡”控制器中的视图调用:
@(Url.Action("ShowImage", "CreditCard"))/" + ConcatString
from src propery of IMG tag. 来自IMG标签的src属性。 but because it from other controller the URL is invalid.
但由于来自其他控制器,因此该网址无效。 Insted Of:
插入的:
/creditcard/showimage/45809014157220320
Its: 它的:
/Transaction/TransactionToPDF/creditcard/showimage/45809014157220320
Wild guess, your Action doesn't accept a null
for the image id? 大胆的猜测,您的操作是否不为图像ID接受
null
? Rather than trying to add concatstring
try specifying the parameter eg, 与其尝试添加
concatstring
尝试指定参数,例如,
@Url.Action("ShowImage", "CreditCard", new { ImageId= ConcatString })
Again, depending on what the allowed parameters are for the Action this should let the correct URL be resolved by the routing system 同样,根据操作允许的参数是什么,应该让路由系统解析正确的URL。
Of course you can use Html.Action helper. 当然,您可以使用Html.Action帮助器。 But it is easier for me to do it like this.
但是,对我来说,这样做比较容易。
<img src="/CreditCard/ShowImage/@ConcatString" class="img float-xs-right" width="350" height="380" id="creditCardImage" />
I think you have an "Area" issue. 我认为您遇到了“区域”问题。 If they are in different areas, you should be able to do this:
如果它们在不同的区域,则应该可以执行以下操作:
@(Url.Action("ShowImage", "CreditCard", new { area = "" }))/" + ConcatString
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.