Reputation: 435
I recently switched from MVC2 to MVC3 and my images are no longer rendering correctly on the development server.
Here is the code:
<img src="@Url.Content("/content/images/sign_up.png")" height="50" width="550" />
Please note I use 'img' instead of 'image in the actual code but I could not post that.
When I look at the rendered HTML it says
<img src="/content/images/sign_up.png" height="50" width="550" />
When I try the URL localhost/content/images/sign_up.png
the image shows up correctly.
Am I doing something wrong with MVC3, or maybe I need to make an adjustment to the IIS server?
Upvotes: 0
Views: 1334
Reputation: 16174
You are missing a ~
sign:
<img src="@Url.Content("~/content/images/sign_up.png")"
height="50" width="550" />
From MSDN:
Url.Content
Converts a virtual (relative) path to an application absolute path.
But to do that, you need to tell it you're passing a virtual path, which is achieved with the ~
.
Upvotes: 1