Home/ASP.NET Forums/Advanced ASP.NET/HttpHandlers and HttpModules/HTTPHandler for images

HTTPHandler for images [Answered]RSS

3 replies

Last post Jul 12, 2010 12:33 AM by ignatandrei

.NET Teacher | .NET Videos 5 minutes
  • helpjet helpjet

    Member

    207 Points

    450 Posts

    Re: HTTPHandler for images

    Jul 11, 2010 09:33 PM|helpjet|LINK

    I was calling handler with a wrong name. Initially I was calling it as

    id.src = "imgHTTPHandler.ashx?imageID="+imageID;

    Correct name of the handler was

    id.src = "imageHTTPHandler.ashx?imageID="+imageID;

    But by looking you post, I am unable to understand the difference b/w Server.MapPath and ResolveUrl

    Also Suppose, if I don't know which folder has "myImage.jpeg". How can I use Server.MapPath(.......?.......) to map the "myImage.jpeg". I tried this "Server.MapPath("myImage.jpeg") but it did not work. DO I have to always provide the complete path or is there any majic in .Net


    Replies.AsEnumerable()
    .Where(rep =>rep.YouLookingFor.Equals('helpjet'))
    .Select (new {Mark As Answer = 'helpjet'})
  • ignatandrei ignatandrei

    All-Star

    119988 Points

    27905 Posts

    Moderator

    MVP

    Re: HTTPHandler for images

    Jul 12, 2010 12:33 AM|ignatandrei|LINK

    It was my mistake again

    instead of

    id.src = '<% = ResolveUrl("imgHTTPHandler.ashx") %>?imageID='+imageID;

    I was meaning

    id.src = '<% = ResolveUrl("~/imgHTTPHandler.ashx") %>?imageID='+imageID;

    I was not sure that you reference the imgHTTPHandler from the right location

    About Server.MapPath and ResolveURL = basic do the same - but , in aspx page, you do not have a Server.MapPath.

    helpjet

    if I don't know which folder has "myImage.jpeg". How can I use Server.MapPath(.......?.......) to map the "myImage.jpeg"

    Server.MapPath("~/relative path to myimage")
    But you have already done this,
      

    path = HttpContext.Current.Server.MapPath("~/Images/" + imageFile); 

    isn't it ?

    .NET Teacher | .NET Videos 5 minutes
  • ‹ Previous Thread|Next Thread ›