I'm a beginner with ASP.NET MVC and I'm trying to set the src of an image with razor in a asp.net MVC website using an If statement.
this code works :
<img src="@Url.Action("GetPersonPhoto", "Home", new RouteValueDictionary( new { cardid = "696969" }) )" />
I want to add :
@if(Model.HavePhoto)
And set the src to :
"~/Content/images/header-logo.png"
if HavePhoto is false...
How can I do it ?
GetPersonPhotoaction decide which image to use and handle cases whereModel.HavePhotoare false, providing the url of a default image, as oppose to handle this in the view layerimgtags, one in the if and one in an else for each case