views:

192

answers:

2

Hello guys,

I have an application using MVC. In my controller I have their a viewdata[] which contains the image path (Viewdata["dd"]=new Control().ResolveUrl(path)). This will work on my local but on the deploy it will not work anymore.

Anybody have experience this scenario?

Your reply is greatly appreciated.

Best

A: 

Why not use this:

Controller:

ViewData["dd"] = path;

View:

<img src='<%= Url.Content((string)ViewData["dd"])%>' alt="" />
korchev
+1  A: 

Try this:

ViewData["dd"] = System.Web.VirtualPathUtility.ToAbsolute("~/RelativeAddress");

Keep in mind that this will throw exceptions if you have any query parameters in your URL. To resolve URLs with query paramters you'll have to temporarily remove them before you resolve and then add them back in later.

Dan Herbert