質問

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"/>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top