In controller I have the action "GetPhoto":
public FileResult GetPhoto(int id)
{
...
}
Also, I have Razor code where I'am trying to dynamically add ID parameter from the model:
@model ISPIS.Models.KodFazeBiljke
...
<img src="@Url.Action("GetPhoto", new { id = model.KodFazeBiljkeId })" alt="" width="250" height="190"/>
However, it's not possible to write "id = model.KodFazeBiljkeId" because, model does not exist in the current context.
Any solution? Thanks!
Your approach should work -- just have to refer to the model with the upper-case Model
:
<img src='@Url.Action("GetPhoto", new { id = Model.KodFazeBiljkeId })' alt="" width="250" height="190"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With