locked
ImageLocation Doesn't Work With Absolute Paths RRS feed

  • Question

  • I tried to set the imagelocation to an absolute path and get the following error:

     System.Web.HttpException: 'G:\software\tribe\archivist\prototype\charterrormvc\MvcApplication1\temp\ChartPicture9cbda576-bdcd-457c-9254-8b0008789e11.png' is not a valid virtual path.
    
    
    [HttpException (0x80004005): 'G:\software\tribe\archivist\prototype\charterrormvc\MvcApplication1\temp\ChartPicture9cbda576-bdcd-457c-9254-8b0008789e11.png' is not a valid virtual path.]
      System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options) +8862651
      System.Web.UI.Page.MapPath(String virtualPath) +25
      System.Web.UI.DataVisualization.Charting.Chart.Render(HtmlTextWriter writer) +462
      System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27

    However, if I use a virtual path to the exact same directory:

     "~/Temp/ChartPicture#UID"

     everything works fine.

    The docs state that an absolue path is allowed: http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.chart.imagelocation.aspx 

    What is going on?

     

    Friday, April 30, 2010 7:21 PM

Answers

  • I have confirmed with MS that this is a bug in the documentation. You cannot use an absolute path in combination with the ImageLocation property. 
    Friday, April 30, 2010 9:44 PM

All replies

  • It doesn't know the UNC. You should have an Images folder within your web app.

    When ASP.NET runs it's actually in your c:\windows\.net\temp asp folders ( thers more folder names than that)

    Move your image into the directory or your will need to Map the path and give permissions. Pictures should be in a themes folder anyhow inside your web app.

    Friday, April 30, 2010 7:33 PM
  • What doesn't know the UNC? As far as I can tell from the stack trace, it sure looks like the

    System.Web.UI.DataVisualization.Charting.Chart.Render
    method is calling MapPath instead of examing the path to see if it is already absolue and thus doesn't need to create a virtual path.
    Friday, April 30, 2010 8:35 PM
  • I have confirmed with MS that this is a bug in the documentation. You cannot use an absolute path in combination with the ImageLocation property. 
    Friday, April 30, 2010 9:44 PM