Before starting, I've seen this asked here before and I've followed the answer and examples given here:
how to display image from path in asp.net mvc 4 and razor view
But when i do
<img src="@Url.Content(Model.ImagePath)" class="dker" alt="..." />
I get an error
Source Error
[No relevant source lines] [NullReferenceException: Object reference not set to an instance of an object.]
In my model:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NSProfileImages
{
public class ProfileImages
{
public string ImagePath
{
get
{
return "~/Assets/Images/user_images/avatars/[email protected]";
}
}
}
}
View:
@model NSProfileImages.ProfileImages
<img src="@Url.Content(Model.ImagePath)" class="dker" alt="..." />
If I do
<img src="~/Assets/Images/user_images/avatars/[email protected]" class="dker" alt="..." />
it will display the image normally and no errors.
null? How are you providing the model to the view?