views:

44

answers:

2

My ASP.NET MVC web app requires the upload of image files. These image files are then displayed via a partial view rendering where the path of the image file is inserted into the scr parm of the image tag. This works great in development mode however when I deploy to the server the images won't display. I have tried many way to specify the path including ResolveClientUrl to no avail. As a test I hard coded the path of some images that were not uploaded but part of the original content and they display fine from the server. Here is the partial with some additiona image tags inserted for testing. Again all display fine on my local dev environment but when deployed to the server don't. I have set an alert to capture what is returned from my partial view and the paths look fine. Please any suggestions appreciated.

 <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
 <%@ Import Namespace="ULS_Site.Models"%>

   <table>

<%string equipID = ""; %> ' /> <% foreach (var item in ViewData.Model as IEnumerable) %> <%{%> " alt=" " /> <%equipID = item.entity_id;%> )" value="Delete" style="width:45px; font-size:11px" />
<%}%>

A: 

You should use Html.Image helper method. That resolves the path for you.

<%= Html.Image(“myImage”, “~/Content/yourImage.jpg”, “A picture of you”) %>

Ref: http://stephenwalther.com/blog/archive/2009/02/18/asp.net-mvc-tip-47-ndash-using-resolveurl-in-an-html.aspx (it's in his book too).

David Elizondo
A: 

Thanks David _I will check into that however I discovered the issue was with the name of my image folder 'equip_Images'. Once I changed it to equipImages' my issue was resolved. It was strange because as I said in my original post - this was not a problem on my dev machine.

MikeD