This is a migrated thread and some comments may be shown as answers.

Illegal characters in path - ExportToPDF

7 Answers 225 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Martin Roussel
Top achievements
Rank 1
Martin Roussel asked on 05 Sep 2012, 05:50 PM
Hi, I have a RadGrid defined below. When I click the built-in "Export to PDF" button I get the error listed below:

<telerik:RadGrid ID="RadGrid4" runat="server" Width="99.7%" PageSize="20" AllowPaging="false"
                            AllowSorting="True" AllowFilteringByColumn="false" AllowMultiRowSelection="True"
                            ShowGroupPanel="false" GridLines="None" ShowFooter="false" ShowHeader="true" GroupingEnabled="false"
                            Skin="WebBlue" EnableHeaderContextAggregatesMenu="false" EnableHeaderContextMenu ="false"
                            AutoGenerateColumns="false" EnableViewState="True"
                            OnItemCommand="RadGrid4_OnItemCommand" OnDetailTableDataBind="RadGrid4_DetailTableDataBind" OnItemDataBound="RadGrid4_OnItemDataBound" OnNeedDataSource="RadGrid4_NeedDataSource"
                            OnGroupsChanging="RadGrid4_OnGroupsChanging" OnColumnsReorder="RadGrid4_OnColumnsReorder">
                             
                            <MasterTableView HierarchyLoadMode="ServerBind"
                             CommandItemDisplay="Top" CommandItemSettings-ShowAddNewRecordButton="false"
                             CommandItemSettings-ShowExportToExcelButton="true" CommandItemSettings-ShowExportToWordButton="true"
                             CommandItemSettings-ShowExportToPdfButton="true" CommandItemSettings-ShowExportToCsvButton="true" AllowMultiColumnSorting="true"
                             Caption="">
 
                                 <Columns>
                                        <telerik:GridTemplateColumn HeaderText="Name" meta:resourcekey="labName" UniqueName="strEnterpriseSiteContactNameValue" HeaderStyle-Width="50%" Resizable="true" Reorderable="true" SortExpression="strEnterpriseSiteContactNameValue">
                                            <ItemTemplate>
                                              <%# Eval("strEnterpriseSiteContactNameValue")%>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
 
                                        <telerik:GridTemplateColumn HeaderText="Title" meta:resourcekey="labTitle" UniqueName="strEnterpriseSiteContactTitleValue" HeaderStyle-Width="50%" Resizable="true" Reorderable="true" SortExpression="strEnterpriseSiteContactTitleValue">
                                            <ItemTemplate>
                                              <%# Eval("strEnterpriseSiteContactTitleValue")%>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
 
                                        <telerik:GridTemplateColumn HeaderText="Company" meta:resourcekey="labCompany" UniqueName="strEnterpriseSiteContactCompanyValue" HeaderStyle-Width="50%" Resizable="true" Reorderable="true" SortExpression="strEnterpriseSiteContactCompanyValue">
                                            <ItemTemplate>
                                              <%# Eval("strEnterpriseSiteContactCompanyValue")%>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        
                                  </Columns
 
                                        <DetailTables>
                                            <telerik:GridTableView ShowHeader="false" Name="Detail">
                                                <Columns>
                                                    <telerik:GridTemplateColumn HeaderText="" UniqueName="strEnterpriseSiteContactField" HeaderStyle-Width="25%" ItemStyle-CssClass="GridFieldColumn" Resizable="true" Reorderable="true">
                                                        <ItemTemplate>
                                                          <%# Eval("strEnterpriseSiteContactField")%>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn HeaderText="" UniqueName="strEnterpriseSiteContactFieldValue" HeaderStyle-Width="75%" Resizable="true" Reorderable="true">
                                                        <ItemTemplate>
                                                          <%# Eval("strEnterpriseSiteContactFieldValue")%>
                                                          <asp:HyperLink ID="hlEnterpriseSiteContact" Target="_blank" runat="server" Text='<%# Eval("strEnterpriseSiteContactLinkResource")%>' NavigateUrl='<%# Eval("strEnterpriseSiteContactLinkValue")%>'></asp:HyperLink>
                                                          <asp:Image runat="server" ID="imageProfile" ImageUrl='<%# "ImageHandler.ashx?FileLocation=" + DataBinder.Eval(Container.DataItem, "strEnterpriseSiteContactProfileImageDirectoryPath") + "&FileName=" + DataBinder.Eval(Container.DataItem, "strEnterpriseSiteContactProfileImageFilePath") %>' AlternateText="" Height="80px" Width="65px" BorderWidth="0"></asp:Image>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                </Columns>  
                                            </telerik:GridTableView>
                                        </DetailTables>
 
                            </MasterTableView>
 
                            <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
 
                                    <ClientSettings AllowRowsDragDrop="false" AllowDragToGroup="false" AllowColumnsReorder="false" ReorderColumnsOnClient="false" ColumnsReorderMethod="Reorder">
                                        <Resizing AllowRowResize="False" EnableRealTimeResize="True" ResizeGridOnColumnResize="false" AllowColumnResize="true" AllowResizeToFit="true"/>
                                        <Animation AllowColumnReorderAnimation="false" AllowColumnRevertAnimation="true" />
                                        <Selecting AllowRowSelect="false"  />
                                    </ClientSettings>
 
                                    <SortingSettings SortedBackColor="Azure" EnableSkinSortStyles="false" />
 
                           <GroupingSettings ShowUnGroupButton="true" />
 
                        </telerik:RadGrid>

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.SystemException: System.ArgumentException: Illegal characters in path.
  at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str)
  at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
  at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)
  at System.Web.InternalSecurityPermissions.PathDiscovery(String path)
  at System.Web.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping)
  at System.Web.HttpRequest.MapPath(VirtualPath virtualPath)
  at System.Web.HttpServerUtility.MapPath(String path)
  at Telerik.Web.Apoc.Image.ApocImageFactory.TryMapPath(String path, String& physPath)
  at Telerik.Web.Apoc.Image.ApocImageFactory.Make(String href)
  at Telerik.Web.Apoc.Fo.Flow.ExternalGraphic.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.TableCell.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.TableRow.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.AbstractTableBody.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Table.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.TableCell.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.TableRow.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.AbstractTableBody.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Table.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area, Region region)
  at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
  at Telerik.Web.Apoc.StreamRenderer.Render(PageSequence pageSequence)
  at Telerik.Web.Apoc.Fo.FOTreeBuilder.EndElement()
  at Telerik.Web.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)

I found out that it has to do with the ImageURL of the <asp:Image> contained in of the child grid column. If I put a URL link (like "http://somedomain.com/someimage.jpg") it exports correctly.

Is there a way to workaround this or, worse case, handle the export event and remove the image from the export?

Thanks

7 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 10 Sep 2012, 03:11 PM
Hi Martin,

It is hard to say what is causing the problem as the provided information is not enough. Please check the url that you are passing for invalid characters and the ImageHandler as well. For further investigation we will need a small sample where the issue could be observed so we can test it locally.

All the best,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Martin Roussel
Top achievements
Rank 1
answered on 11 Sep 2012, 12:17 PM
Thanks for the reply. Ive investigated more regarding the URL im passing and the actual value passed is:

ImageHandler.ashx?FileLocation=C:/Images/New%20Folder&FileName=bobby.jpg

It seems to be the "?" that is not accepted.

As you can see, im using a Generic Handler control (that read the files and write them as a response stream), in order to be able to display images stored outside my project folder. In my case, im always passing two parameters to specify the directory and then the file. Is there a cleaner way to do this? I see a lot of people talking about creating IIS virtual directories with aliases and using them like relative paths.

Thanks,

Martin
0
Kostadin
Telerik team
answered on 14 Sep 2012, 12:07 PM
Hello Martin,

The problem is not in the "?" character. I attached a sample where you could see that in the URL of the image has a "?" character and the image is exported properly. Could you try to reproduce the problem in a small sample or in my project so we can test it locally.

Greetings,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Martin Roussel
Top achievements
Rank 1
answered on 17 Sep 2012, 01:06 PM
Thanks Kostadin for the reply. Ive inspected your sample and cant find where is the URL with the "?" you're talking about. It looks like your grid contains a RadBinaryImage column which is mapped to a Image data contained in the database (no URL needed).

In my case, there is no image contained in my database and as you can see, im using a GridTemplateColumn containing an asp:Image where the ImageUrl is mapped to a path string from the database.

Or maybe im not looking at the right place?

Martin
0
Kostadin
Telerik team
answered on 20 Sep 2012, 09:48 AM
Hi Martin,

I reproduced your issue. I am forwarding it to one of our developers for further investigation. I will let you know as soon as we have some progress of the problem.

Greetings,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Martin Roussel
Top achievements
Rank 1
answered on 04 Feb 2013, 08:28 PM
Kostadin, any news about this bug ive reported? Is it possible to track it in the PITS?

TIA

Martin
0
Kostadin
Telerik team
answered on 07 Feb 2013, 11:32 AM
Hello Martin,

I am not completely sure when the fix will be available but you could track the progress at the following link.

All the best,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Martin Roussel
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Martin Roussel
Top achievements
Rank 1
Share this question
or