You must Sign In to post a response.
  • Category: ASP.NET

    Image path is not reterive from server

    On server Image is reterive proper. In Web Cofig i did give the Path of image that path is reterive on my page.
    Now i did take the project from server on local machine but image is not reterive. How i can do it, what changes i should change in the code.

    Code is given below:

    In Web Cofig There is One Line: <add key="ImageFolder" value="C:\IMAGE_FILES\"/>

    Image Icon will show below the code.

    protected string GetImagePath()
    {

    return Request.ApplicationPath + "/images";
    }

    if (drawCrossTeam)
    {
    strReqTable.Append("<td class=\"td50\"><table width=\"100%\" height=\"80\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" class=\"border\">");
    strReqTable.Append("<tr>");
    strReqTable.Append("<td width=\"34%\"><img id=\"btnLms\" src=\"" + GetImagePath() + "/salestrack_ibfsl.jpg\" style=\"cursor:pointer\" onclick= \"return OnSystemChange('USERCOMPANY');\" /></td>");
    strReqTable.Append("<td width=\"1%\" valign=\"top\" background=\"images/divider.jpg\"> </td>");
    strReqTable.Append("<td width=\"55%\" valign=\"top\" class=\"content\">");
    strReqTable.Append("Salestrak System for :<br />");
    strReqTable.Append("- Home Loans<br />");
    strReqTable.Append("- Home Equity</td>");
    strReqTable.Append("</tr>");
    strReqTable.Append("</table></td>");
    drawCrossTeam = false;
    break;
    }
  • #768041
    Hi Nitin,

    As you mentioned server. So I got this doubt Do you have access for C: in server?
    Usually this access issue will come up when you don't have access for server, particularly C:

    Kindly try out the some turnarounds. Create a folder in D: Drive and give full access to that folder for all the users and check the path in the coding which should mapped to D: then try to access the image through code.
    If that works, you can clearly understand its access based issue.

    Thanks,
    Mani

  • #768067
    Hai Nitin,
    I can't see in your code, where you are using the path which you have mentioned in the config file. if you are expecting that the path
    background=\"images/divider.jpg\"> </td>");
    should get the image then you need to append the path which you have mentioned in the configuration.
    Also Request.ApplicationPath will always point to the virtual path of the browser which is currently accessing the site.
    So if you want that it should take the path you have mentioned in your config file, you need to first get the config file path and then append it to the URL as:
    as:

    protected string GetImagePath()
    {
    var path = System.Configuration.ConfigurationManager.AppSettings["ImageFolder"].ToString();
    return System.IO.Path.Combine(path, "/images");
    }

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


  • Sign In to post your comments