0

Can some one tell me if I how I can use Url.Content when my URL contains an embedded code nugget like below?

<a class='highslide' id="baseThumb" href="../../Helpers/ImageHandler.ashx?imageid=<%= Model.ImageIDs[0] %>&thumbnail=0">
<img runat="server" src="../../Helpers/ImageHandler.ashx?imageid=<%= Model.ImageIDs[0] %>&thumbnail=1" alt=""/>
</a>

My image above only gets display on my local development environment, never when I deploy to a server. The ImageHandler is not found due to the URL being incorrect.

Thanks

1 Answer 1

1

Try this:

<% 
    var url = Url.Content("~/PATH/Helpers/ImageHandler.ashx?imageid="  + Model.ImageIDs[0]);
%>

<a class='highslide' id="baseThumb" href="<%=url%>&thumbnail=0">
<img runat="server" src="<%=url%>&thumbnail=1" alt=""/>
</a>

The ~/ in Url.Content will point to the root, so from there you will have to set the correct path to the ashx file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.