Wednesday, 11 September 2013

ASP.Net MVC image not displaying

ASP.Net MVC image not displaying

I have a view with the following -
<img src= "@Url.Content(new Uri(image.Path).AbsoluteUri)" alt="@(new
Uri(image.Path).AbsoluteUri)" />
image.Path is a string
It renders the below html
<img alt="file:///C:/Users/Tom/MyAppApp_Data/uploads/myImage.jpg"
src="file:///C:/Users/Tom/MyAppApp_Data/uploads/myImage.jpg">
But the image is not displayed in the browser.
If I open FireBug and hover over the image element, the image will show in
the FireBug window.
If I take the above html and place in a test.html file and open the file
in a browser, the image is displayed.
However, if I hard code the above html into my view, it does not work!

No comments:

Post a Comment