Ballon Ura
Ballon Ura

Reputation: 922

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. but because it from other controller the URL is invalid. Insted Of:

/creditcard/showimage/45809014157220320

Its:

/Transaction/TransactionToPDF/creditcard/showimage/45809014157220320

Upvotes: 0

Views: 125

Answers (3)

ScottGal
ScottGal

Reputation: 31

Wild guess, your Action doesn't accept a null for the image id? Rather than trying to add concatstring try specifying the parameter e.g.,

@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

Upvotes: 1

Daniel Lorenz
Daniel Lorenz

Reputation: 4336

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

Upvotes: 0

DLL_Whisperer
DLL_Whisperer

Reputation: 827

Of course you can use Html.Action helper. 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" /> 

Upvotes: 0

Related Questions