Re: How to use the Gallery on a page with code-behind?

  •  08-26-2004, 11:00 AM

    Re: How to use the Gallery on a page with code-behind?

    ok, I tried. I created a new project with just DotNetGallery control in an ASPX form set to use a subdirectory with a ready-to-use XML file, photos and thumbnails.

     
    When I access the page like this: http://localhost/TestGallery/gallery.aspx
     
    I get this:

    Access to the path "c:\inetpub\wwwroot\TestGallery\photos\gallery.xml" is denied.

    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.UnauthorizedAccessException: Access to the path "c:\inetpub\wwwroot\TestGallery\photos\gallery.xml" is denied.

    ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

    To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [UnauthorizedAccessException: Access to the path "c:\inetpub\wwwroot\TestGallery\photos\gallery.xml" is denied.]
       System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
       System.IO.File.Delete(String path) +165
       DotNetGallery.Gallery.BindData() +930
       DotNetGallery.Gallery.OnPreRender(EventArgs e) +140
       System.Web.UI.Control.PreRenderRecursiveInternal() +62
       System.Web.UI.Control.PreRenderRecursiveInternal() +125
       System.Web.UI.Control.PreRenderRecursiveInternal() +125
       System.Web.UI.Page.ProcessRequestMain() +1489
    
     
     
    Here's the source of Gallery.aspx:
     

    <%@ Page language="c#" Codebehind="Gallery.aspx.cs" AutoEventWireup="false" Inherits="TestGallery.gallery._Default" %>
    <%@ Register TagPrefix="CE" Namespace="DotNetGallery" Assembly="DotNetGallery" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

    <html>
      <head>
        <title>Default</title>
        <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" Content="C#">
        <meta name=vs_defaultClientScript content="JavaScript">
        <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
      </head>
      <body MS_POSITIONING="GridLayout">
     
        <form id="Form1" method="post" runat="server">
                    <p align="center">
                      <CE:Gallery
                        id="Matryoshka2004Gallery"
                        runat="server"
                        Height="600"
                        Width="680"
                        Column="5"
                        MaxImageWidth="600"
                        BackColor="#DD00AA"
                        CellPadding="5"
                        AutoResizeUploadedImages="false"
                        CellSpacing="5"
                        ForeColor="#FFFFFF"
                        BorderColor="#cc0000"
                        BorderStyle="solid"
                        BorderWidth="0"
                        CssClass="container"
                        ShowThumbNailName="true"
                        ShowThumbNailSize="false"
                        ShowThumbNailDate="false"
                        ShowThumbNailDescription="true"
                        ShowHelp="false"
                        ShowHome="true"
                        ShowNext="true"
                        ShowPrevious="true"
                        HomeUrl="Default.aspx"
                        FolderPath="photos"></CE:Gallery><br>
                    </p>
         </form>
     
      </body>
    </html>

     
    Mind you that gallery.xml is 71KB (250 photos) in size and is ready to use.  If I enable write access to it (and I have to explicetely give full access to practically all user accounts the file) then DotNetgallery will first overwrite it with an XML file without photo info (2KB) and then, on a repeat attempt I will get permission denied again.
     
    So it looks like it might be some type of permission issue, however I'm clueless right now. At least I would expect DotNetGallery to read an availble read-only XML file, then I would have a work around by building the XML file in your example project
View Complete Thread