Photo Album handler 2.0

Last night, I uploaded the source code and release package for version 2.0 of the photo handler. I'll post more about the details of this new version in the next few days, but I can tell you that most of it has been rewritten, and it can now be used as a standalone application or as a control. What's more, the control is fully templatable, so if you don't like the default rendering, you can take it over and create your own. I've included a template example that reproduces the default rendering, which should give a good starting point.

Download the handler from here:
http://www.codeplex.com/PhotoHandler

UPDATE: the handler is now hosted on Codeplex.

94 Comments

  • Thanks alot for a very cool component. It would be even nicer if you could start a slide show in which you could choose how many seconds you want it to wait between each fully loaded picture. Perhaps some Ajax/Atlas could take care of that?

  • NiklasEngfelt: Yes, this is on the list of things to do.

  • Alex: can you give me a little more context? What version of ASP.NET are you using? What did you do exactly, etc.? Drop me e-mail at bleroy (microsoft.com)

  • Hello

    I think this album handler is ideal for building photo albums in an intranet, where people have file access to the server via a share. So upload is simple...

    Unfortunately the album handler is not working on Windows 2003 server. No such problems on Windows 2000 server.

    I get the follwoing error:

    Parser Error Message: User control source files must have a .ascx file extension.

    and the follwing line is highlighted red:

    Line 2:


    Do you have a hint how to get the album running on Windows 2003? Or do you know of another product offering the same functionality?

    Thank you!

  • Thowe: I'm running it at home on 2003 so that can't be the problem. Are you sure you have ASP.NET 2.0 installed? Apparently you're using the handler as a user control in a page. Does it work when you hit it directly?

  • If you're getting the "User control source files must have a .ascx file extension." error and you have framework 2.0 installed, then you probably have the virtual directory configured to use framework 1.1. On my machine 1.1 is default and I have to set it to 2.0 explicitly in IIS.

  • i was trying to download the code to intrigate into my home server and i keep getting the following message

    The GotDotNet site is being phased out
    Microsoft will be phasing out most features of the GotDotNet site by Summer 2007.
    GotDotNet Workspaces and Private Workspaces have been phased out More about the GotDotNet phase-out
    Contact the GotDotNet Support Team


    is the code still available for download and if so where can i get it?

  • Yes, hold on, I'm migrating to Codeplex. The new address will be: http://www.codeplex.com/PhotoHandler

  • Hello,

    I like your Photo Album handler 2.0 very much, but I've a problem.
    Ich can't publish the website.

    Here is the errormessage (sorry - it's in german):
    "Für die Erweiterung .ashx ist kein Buildanbieter registriert. Sie können einen im -Abschnitt in machine.config oder web.config registrieren. Stellen Sie sicher, dass das BuildProviderAppliesToAttribute-Attribut den Wert Web oder All enthält.
    I:\xxx\AlbumHandler2_1_\Default.aspx"

    Could you help me please?


    bye Anke

  • Anke: you should talk to your hoster. Apparently they disabled the build provider for ashx.

  • But I can't publish the website on my own Desktop PC. It runs only with the cassini, ans if I like to publish the Website, I get an Buil-Error.

    I've try to add the Build-Handler to the project (in the web.config) but it dosn't works.
    I have an other Project width a Http-Handler an this project I can publish. I works width Asp.Net since some years, but I havn't wrote a Http-Handler sometimes. I don't know, that I can makew :(

    I have try to publish the Project at an other PC, but I have the same Error-Message :(

    ciao Anke

  • Anke: please check that the directory where you dropped the handler and bin folder is a web application configured for ASP.NET 2.0. It should work just fine out of the box.

  • Anke: I'm sorry, but no, I don't.

  • Anke: the problem is that I'm unable to reproduce your problem. I could do something if you gave me the exact, very precise steps of everything you did from downloading the handler to setting up the web site and running it. Please also include what OS you're using.
    We can continue this discussion through e-mail (bleroy at microsoft dot com) or even better, you can file a bug on CodePlex.

  • I too am having the problem with subdirectories. I have everything in year folders and then month then activity. I can click all the way thru but the last folder I cannot view anything inside it. I get thumbnails but cannot get into the folders. any ideas?

    Dave P

  • Dave: if you can zip a sample site (not too heavy please) and send it to bleroy at microsoft dot com, I can have a look.

  • I'm having what is probably a minor issue with the handler. I have it running on Windows Server 2003, and the index page of folder thumbnails comes up fine, but it won't do anything else. When I click on any of the folders, nothing happens. This seems like a Javascript issue as no ASP errors come up. Have tried it in several different browsers just to be sure. Anyone know of a simple fix before I start digging into the code?

  • Luke: do you have a url where I could have a look at that?

  • Awesome....exactly what I was looking for.

  • I have an intranet site, and all i did was dumped the files that I downloaded into a folder in the intranet site. Is that sufficient?
    I get this error:
    Parser Error Message: The file '/Intranet/album.ashx' does not exist.
    Although the file is obviously there. Is there something i have to do with the dll?

    thank you.

  • Big Doe: the dll just needs to be in the bin folder. If you downloaded the release file and uncompressed it into a folder that's configured as a web application, it should work directly.

  • Hi, sorry for my ignorance on this subject, but do I need to configure it as a web application on the web.config file? I have created a application pool called "photoalbum" in IIS 6, although Im not sure its necessary.
    If this is to be done on the web.config file, where on the file do I configure it? thank you so much for everything!

  • Thanks for everything, i figured it out. It was not hard at all actually. I placed the dll in the bin folder and make sure of the path of the ashx file on the default.aspx file, and viola! thanks for everythign all, this is awesome!

  • Sorry for being such a nusance, but how do I control it so that when you go to for example: album/default.aspx, the folder view only shows folders inside of the album folder, and not the folders of the entire web directory?
    Right now, the bin folder is in the intranet/bin folder so everything under intranet is being shown in the folder view. Thank you so much.

  • Big Doe: just put the handler in the folder where you have the photos (don't move anything else, just the ashx. If you're using the handler as a control (and apparently you are), there is a bunch of properties on it, in particular HandlerUrl and Path, which should enable you to do that.

  • I am very excited to find this program and it does exactly what I need to show photos of our work to customers (and especially potential customers!). My only problem is that it is displaying all of our directories (ie Admin, Secured, etc) on the main page. How can I restrict it to only look for pics in specific folders such as "WorkPics"? I wish I knew as much as you guys!

  • Madtown: see above comments. Big doe had almost the same question.

  • A quick question:
    I want to have some one click on a link that will take them to one of the folders in the album, is there a way to reference it? Through a href like ...default.aspx?folder="vacationfolders"

    Thank you, and sorry if these questions are juvenile, I am very new to this.
    thx again.

  • Big Doe: take a look at the Permalink property on the control. If you're using it as a handler and not as a control, just copy the url.

  • Thanks for the reply, but where can i get the url of the specific folder?
    right now I have the link set to:
    intranet/album/default.aspx?"albummode=preview&albumpath=vacation"
    This is the right syntax?

    vacation is the name of the folder.
    I cannot get this to work, please help! =(

  • Why the quotes? I suppose it should work without them. The PermaLink property should just give you the right url iirc.

  • thanks again, I hate to be pestering you with stupid questions, but how do you use the permalink property to give me the right url? =(
    I guess this will help many other novices as well.

  • You set the NavigateUrl of a hyperlink control to its value for example.

  • IM sorry, i am about to give up. Where in this area do I set it?





  • Madtown: This happens when you don't have sufficient priviledges to write thumbnails to the temporary directory. You can check that by trying to browse directly to the url of one of the thumbnails and check the error message.
    The workaround is usually to set the application to high trust, or if you can't, switch the caching mode in the handler's configuration from disk to memory or none.

  • Thanks for all your help.
    One more question. =)
    What part of the code would you have to change in order to make it so that if you click on the thumbnail, a new window pops up with the photo?

    Thank you so much in advance, this is an awesome tool.

  • Big Doe: look for the GenerateFolderPage method. Then look for the loop over images that's in there. In there, you can see code that renders the A tag. Add a target attribute in there and use "_blank" as the value. That should work. If you want more control over the size and appearance of the new window, you may want to use an onclick instead and some basic window.open javascript.

  • Thanks Betrand Le Roy:
    This is what I have:
    writer.RenderBeginTag(HtmlTextWriterTag.A);

    writer.AddAttribute(HtmlTextWriterAttribute.Target, "_blank", true);

    The second line should create a new window when the user clicks on the thumbnail, no? I saved the ashx file and it still showing in the same window. Anything I am doing wrong?

    Thank you so much!

  • The attribute has to be written *before* the tag.

  • Worked Perfectly! THanks alot! Our entire office is going to love this, I'll make sure the wonderful person(s) behind this awesome program be known.

  • I'm having the same problem as madtown. I put the ashx file in the folder with the images i want to display and i have changed the handler's configuration from disk to memory and none. It still doesn't show the pictures until i click the last one.

    Otherwise this is a really cool program. Thanks :)

  • Dev Girl: please contact me through the contact form of this blog, and I'll have a look.

  • Actually I just figured it out. Thanks for the quick response. It looks great!!

  • Hi all, anyone know a way to skip the preview and go to the full resolution when cliking on the thumbnail and also to a new window?
    thanks!

  • Big Doe: in generateFolderPage, there is a loop over images. You can change the rendering from there so that the link's href is pointing to image.Url instead of image.Link. You also want to add a target attribute with the value "_blank" to open in a new window.

  • Hi. This Photo Handler really rocks. Thanks for providing it.

    I see it is already mentioned in the comment from Anke. When I run my project on my localhost everything works very fine, but as soon as I try to Build --> Publish Web Site, then I get an error

    "There is no build provider registered for the extension '.ashx'. You can register one in the section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'."

    I'm using VS2008 Beta - it can off course be something with that. However the project im using is in 2.0 not 3.5

    I have tried to add a buildProvider as explained, but I cannot see how I can add the attribute that is mentioned.

    Did you manage to find a solution with Anke or did you stop researching. Thanks in advance

    Regards
    Darksaint

  • Darksaint: please verify that the IIS application is configured to use 2.0.

  • Bertrand: Yes the IIS application is configured for 2.0 - it's on windows vista - so it's IIS 7.0 but I don't think that should be an issue.

    It's pretty strange as soon as I exclude the ashx file from the project then I can publish/compile the projet but when I include it and try again - then I get the error message that i mentioned before, incredible frustrating *hehe*

  • Oh, right, I see. The build/publish thing doesn't work and probably never will because we have both a control and a handler in the same file and, well, weird things happen. So in the end, you don't build this from VS, you just drop it on your server and ASP.NET will do the compilation. Makes sense?

  • Bertrand: Yes it makes sense - actually i did just leave out the page that uses the ashx file when I compile and then I manually upload the page afterwards - that works - I was just puzzeled about the error message and it could be there was some nifty solution to that. Anyways thanks for good support and a kickass handler :)

  • Chetana: Sure, if you're using the control in templating mode, the image objects have a Caption property that you can add to the template.
    Adding a file upload control should be no problem at all provided you're careful about authorizations.

  • Subject is sort of self explanitory. I got this to work no problem locally in VS.NET 2005. Put everything up on my hosted site (DiscountASP.net hosting) and get no images. No error messages - just no images.

    Tried it with all 3 flavors of caching. No change. I verified that I'm running framework 2.0.

    Not sure where to look next....

  • Doh! Yes, a handler makes it work much better...

    Doesn't seem to matter what I set for path though, I end up getting a server error:

    Value cannot be null.
    Parameter name: value

    Line 1563: if (path != _requestDir && !path.StartsWith(_requestPathPrefix)) {

    If I leave it blank I get images for everything except the folder navigation

  • Matt: I'm suspecting that you have a .jpg file in that directory that is not a valid jpeg.

  • Matt, do you *need* to change the path?
    I don't know if it would work with a directory that's on your network. Don't see why not. File a bug on the CodePlex site if it doesn't.

  • Not 100% sure is I need to change the path or not. I need to keep the album.ashx file somewhere other than where the pics are.

    This is part of the strategy to use a network share to house the images. I'll have read only access to the image share, and no ability to execute code that resides there.

    The album.ashx file will need to live in a physical folder on my web server, and the photo store will be a virtual directory as a sub folder of this real folder.

    Either way, the album.ashx code doesn't see to recognize a UNC connected virtual directory. I'll list it on Codeplex.

  • Thanks, Matt.

  • Just to inform you of issues in the MetaData library:
    I could see every image album folder in the initial page, but when I click an album image, nothing would happen.

    I found that the metadata library was unable to open my images and thus 'freeze' your application. My images are shot with a Canon 350D and Canon 40D; the MetaData library with your application is outdated (2.2.2, current version: 2.3.0g) and unable to open these photos.
    As someone else already pointed out, replacing the outdated library with the newest will result in .NET binding errors.

    When I disabled the Metadata parts in the ASHX, I was able to browse the directories successfully.

  • Thanks for the report. Please file a bug on CodePlex.

  • Hello,

    i'm tryng to change the color from the thumbnails to white and i cant find where do i chenge!

    ive change this part and works only for the preview images not for thumbnails (next and preview images):

    private static readonly Color BackGround = Color.White;

    thanks for the help!

  • Marcos: http://www.codeplex.com/PhotoHandler/WorkItem/View.aspx?WorkItemId=2067

  • Hi, This has been working great, but all of a sudden we get this message:
    javascript:WebForm_DoCallback('Album1','p/jacksonhole/IMG_0210%20(f).jpg',photoAlbumCallback,'Album1',null,false)

    after clicking on an image.
    I set it a long time ago to open up in a new window with this line:
    writer.AddAttribute(HtmlTextWriterAttribute.Target, "_bank", true);

    In the image loop in the gerneratefolder method.

    Any ideas why all of a sudden, with no changes, this will happen?
    thank you!

  • Where are you getting that message? Is it possible that someone disabled JavaScript on your browser?

  • Oh i am sorry, the message I get is Page cannot be found.
    Javascript is not disabled, i reloaded the file, and it works but as soon as i add the extra line, i get that error. I get this message on the new window as soon as I click on an image, the line I added opens up a new window which displays the page cannot be loaded.

    its the generic "Windows cannot display the webpage" message.

    Does this have anything to do with permissions on the picture folders? I change permissions on the folders where we put in the pictures so others can have access to delete and add pictures.
    Thank you

  • You mean you added target="_blank" on links that do a postback? Sure, that can't work, postbacks have to happen in the same window. Using a different target is only possible on real links, not javascript ones.

  • @Daryl: I'm guessing the handler is not at the root of the web application on the server, and thus the server can't find it at ~/album.ashx.

  • Hi, I downloaded the files from codeplex. I have VS 2005 installed. What I should do? What steps I need to follow?

    I have album.ashx file
    Then Samples directory contains
    Default.aspx
    Templated.aspx
    and Album.css

    Where should I copy these files?
    What file I shoud open in VS 2005? Is their any project?
    How do i assign the directory in which the images are placed?

    Can some one help me? I will create a Video movie and upload in Youtume or any other location for the benefit of others.

    Thanks

  • @John:
    * In a web application on your web server. If you want to use just the handler, you just need bin and the ashx. If you want to use it as a control, you need the rest.
    * Why do you want to open Visual Studio? If you want to open the web site in Visual Studio, just do file/open/web site and point VS to the web application
    * It depends if you're using it as a control or as a handler. If it's as a handler, the images should be in the same directory. If as a control, just set the Path property.

  • When was this version last updated ?, is it possible to list the picture in the order in which they were taken rather than there file date ?

    Create tool btw

  • @Dom: in June 2007.
    The file date is only used as a last resort after the metadata has been searched in at least two different places so if it's not working for you, please file a bug on CodePlex and link to an image where this is not the case.

  • Is possible to change the backcolor to a thumb image?

  • @Kid: http://www.codeplex.com/PhotoHandler/WorkItem/View.aspx?WorkItemId=2067

  • I'll try to insert the propose fix but doesn't resolve the problem!
    Thanks

  • Dropping the album.aspx into the directory with pictures isn't working for me. The only way it is working is to have it in the top level directory. Since I don't own the hosting provide, is there something I should tell them? I was able to use the 1.0 version is a subdirectory, but not the 2.0 version. Or is there a way to hard code the path to the subdirectory?

  • @Rqy: I'm assuming you mean album.ashx. What really needs to be in the web app directory is the bin folder with the dll in it.

  • Yes, I meant album.ashx. Sorry. I have the Bin directory and dll in the top level app directory. It all works when the album.ashx is in the top level directory, but when I try moving album.ashx to a subdirectory, the page that references album.asxh gets an error. I've updated the @register line to reference the subdirectory where I've moved album.ashx. Is this a permission problem or do you have any other thoughts? Thanks.

  • @Ray: please contact me offline (bleroy at microsoft).

  • I just wanted to add that since you allowed for special characters, I assume that you allowed for space as well. I didn't have but three different directories of images to use. The other two directories would display an the thumbnail collection without any problem. But, the filenames in these two directories did not contain any spaces in the filename. The file name in the error had spaces in it, which lead me to assume that spaces was the problem. But I don't know enough about the code to understand what is going on. This particular file mentioned in the error is the last file in the directory. I regret jumping to a conclusion based on my limited knowledge, if indeed my first assumption is incorrect.
    Thank you

  • @noel: spaces shouldn't be a problem. If you can send me a simple repro at bleroy at microsoft I'll have a look.

  • I've successfully migrated the code to use the newest MetaDataExtractor.dll (V2.4.0b)

    Are you intersted in the (minor) changes?

  • @Kevin: I might use a diff, thanks. But I might be unable to include those changes as I've changed the way the library is included since last version was published.

  • Thanks for your works! It's wonderful!

  • This is lovely code. thank you so much!!!!!!!!!!!!!!

  • @Anke: I found the answer to your problem and wanted to post here in case someone else is having a problem publishing their website from VS. After you click on "Publish web site" the "Allow this precompiled site to be updatable" option will be checked. Just uncheck this option and it will publish your website correctly toy our target location.

    See here for more information as to why: http://msdn.microsoft.com/en-us/library/377y0s6t.aspx

    Hope that helps someone else...

  • Hi

    A novice question, how would you hook in a lightbox control that works as you switch through photo folders? I can add the class via writer.AddAttribute, but I am guessing the JS has to be triggered each time a folder is loaded to add new images to the lightbox... any thoughts.... also would it be done in the ashx or aspx (well ascx for me)?
    Thanks

  • @Webturtles: I have no idea how you'd do that. The handler was built to work standalone, not to integrate with other similar products.

  • I guess it would be just another way to present the final album view. Great code though, such an easy way to go through many folders and also to be able to use url parameters, have embedded it as an easy control in MWPSK. Congrats on the great coding.

  • Are there are any installation instructions or 'howtos' for this control? It seems really cool, but I can't seem to get it to show my albums. All I get are hyperlinks with broken thumbnails (image placeholders with an 'x').

  • How do i do an horizonatal listing of my image directories, say i want to have 4 items per line as against having them listed vertically with one item per line.

  • @Oladipo: it should not be a vertical display. That it is in your case indicates that it wasn't properly configured and that you are not getting the stylesheet. Glancing into the network trace in Firebug should confirm that and give you an error message.

  • @Joe: edit the dates.

  • Hi
    I have added your code to website but I need to specify a path to the folder I want it to get the images from. eg I have a page (default.aspx) which has a list of houses, they click to view a house (details.aspx?property=1) on the details page I want it to get all the images that exist in ~/images/propertys/1

    If the above folder does not exist then do nothing

    But when I try and change the Path method on PageLoad of details.aspx I get an error of

    Value cannot be null.
    Parameter name: value

    My OnPageLoad code looks like this

    Album1.Path = "~/images/propertys/1"

    What am i doing wrong

    Many thanks inadvance

  • Attach a debugger and find out...

  • Seems to be working :).Was looking for a simple photoalbum to present my pictures on Wii. Figured outthat I could try with running IIS on XP Pro, so activated it. Created default web, pointing to a picture folder. Downloaded your Handler script, and the seperate Metabase. It could save the hassle if a better how-to was provided. Needed some Googling on the Metabase, to find out in the end that one only needs to extract the metabase zip in the same root directory as all the other files. On tip for those who install IIS after .net was installed: this can give problems as it is a know problem that user rights won't be working correctly to access the metabase. Google is your friend, and for me it was sufficient to run following command:

    aspnet_regiis.exe -ga machine_name\ASPNET

    Layout (CSS) for Opera on Wii is a mess, but hey, it works fine for all the other networked PC's and tablets.

    Nice work, thanks for keeping it available since 2005 !

Comments have been disabled for this content.