asp.net - Image Not Displaying On Page -


i working on mvc 5 asp.net. when using razor syntax image not showing on web page otherwise same hard coded value working.

here code.

    @{        var path = "";     }     @foreach (movy in model)     {             if (a.image == null)             {                 path = "~/content/images/c3.jpg";             }             else             {                 path = a.image;             }         <img src="@path" />     } 

but when replace @path "~/content/images/c3.jpg" in source of image works.

you need resolve string in run time. use url.content

<img src="@url.content(path)" />


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -