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

Last post 08-26-2004, 3:05 PM by Adam. 5 replies.
Sort Posts: Previous Next
  •  08-25-2004, 7:30 PM 1613

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

    Hi Adam,

     
    I downloaded the DotNetGallery because it looks very close to what I'm looking for.
     
    I need to integrate it on a page that has additional user controls (for portal navigation, menus, etc) and code behind for essential intergration with a database.
     
    Whenever I try to access a page with DotNetGallery on it the control tries to create a new gallery.xml file in a directory with photos. If I give write access to that directory then control will overwrite the existing gallery.xml (even though it is up to date). The new XML file is only 2KB in size and doesn't contain any image info. I was able to create a correct XML file and thumbnails by putting my photos in your example directory, and rebuilding it there after granting full access to that directory to every user I could find.
     
    Test license seems to be OK - it finds it, and if I remove it the complains.
    FolderPath is also OK - if I change it to an incorrect path then I get - "Could not find a part of the path ..."
    I copied entire project to a box with WinXP and IIS 5.1 (from Win2003 and IIS 6.0) - same story it will either overwrite it with no image data or I will get access denied error.
     
    File structure is like this
     
    -Web Application Root
    -----/bin (with *.dll & *.lic)
    -----/Gallery (with an *.aspx page which contains DotNetGallery control)
    -----/Gallery/photos (with photos and an XML file)
     
    Any ideas why in my situation DotNetGallery ignores existing XML file?
     
    And another question, what Thumbs.db files are for? When DotNetGallery creates no-image-data XML files on my box then Thumbs.db file does not get created in the same directory.
     
    thanks, Patrick
  •  08-25-2004, 8:28 PM 1614 in reply to 1613

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

    Patrick,

     
    The thumbs.db file is generated by the Windows operating system. It is a database file containing the small images displayed when you view a folder in "thumbnail" view (as opposed to tile, icon, list, or detail view).
     
    I think there are some problems related with your user control which cause the dotnetgallery failt to load.
     
    Can you create a new project just for testing the dotnetgallery?
     
    Keep me posted.
     
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-26-2004, 11:00 AM 1619 in reply to 1614

    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
  •  08-26-2004, 11:51 AM 1620 in reply to 1619

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

    PatMunits,

     
    Your dotnetgallery setting looks good to me. I can't figure out why you can't get it works.
     
    Do you have the same problem when testing the example project comes with the download package?
     
    How did you create the gallery.xml is 71KB (250 photos) ?
     
    Keep me posted.
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-26-2004, 12:55 PM 1622 in reply to 1620

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

    OK, after a few other dead ends I guess I figured it out.

     

    First of all, one running IIS6 must give "FULL CONTROL" rights to a directory where XML file is going to be (I'm not sure which rights are necessary for a directory with photos if they are in a separate from XML file directory). To change rigths use Properties window of that directory in Windows Explorer. The WRITE access setting on that directory set in IIS Manager has no apparent effect.

     

    Now, this means that realistically one should only create/modify galleries only in a secure environment, and then upload read-only galleries to a public server. I don't know how secure is NETWORK SERVICE account is, or any other programs that can use that account.

     

    Then, one must include your DotNetGallery_Files directory included with the "example gallery". Otherwise you will get a blank page with no errors and no idea how come nothing is happening! I believe that I haven't seen anywhere in documentation anything about must having this directory included. I thought that everything was included in the DLL file, and the only things necessary to run the project were: DotNetGallery.dll, DotNetGallery.lic and an optional web.config entry.

     

    I think I should get some special offer for a license purchase 

  •  08-26-2004, 3:05 PM 1623 in reply to 1622

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

    Glad to know you got it resolved.

     
    To get the dotnetgallery works, your file structure should be as followings:
     
    ~/bin/DotNetGallery.dll, DotNetGallery.lic
    ~/DotNetGallery_Files
    Yourphotosdirectory(you need assign the NETWORK SERVICE account write permission to this folder)

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View as RSS news feed in XML