This project is read-only.

Setting Root Directory [imported from GotDotNet]

Jun 21, 2007 at 8:03 AM
Edited Jun 21, 2007 at 8:07 AM

User Posts:
Setting Root Directory Posted on: 06/11/2006 21:15:55

I was able to make this awesome image browser work within it's own virtual directory within my main server directory. For the purposes of implementing this along with the rest of a website, putting it inside it's own virtually directory doesn't make things easy (web.config link to login page, using "~" in links, etc.). I'm wondering if there is a way to specify the root folder for the image browser.

Example: My web server access the root directory /live/ for the live website. I'd like to put photos into folders under /live/pictures/. In addition, I'd put default.aspx and album.ashx in this folder. I put the bin folder in the root folder /live/. When I do this, the page default.aspx begins displaying images (although the image links are broken) from the /live/ directory, so I get a list of all of my directories on the web server.

My question: Is it possible to specify (even if this is not a simple one line fix) the absolute root directory of the photo album (other than using a virtual directory)? I'm quite confused by all of the Path, _path, _filePath variables as I'm still getting acustomed to C#.

Thanks again in advance.

I still love this thing. It's been a great learning tool for me, in addition to a beautiful photo album.


User Posts:
Setting Root Directory Posted on: 06/11/2006 21:16:49

Hey bleroy, it also made Sankar74 now? What's with that?

I'm BrynDN really.


User Posts:
Setting Root Directory Posted on: 06/20/2006 10:45:33

I agree that would be a useful feature. Adding it to the list of things to do. It's probably not a trivial fix but it should be reasonably easy.
I'll add a config setting and a property for the control.

Please open a bug to track it.
Post edited by bleroy on 06/20/2006 10:46:35


User Posts:
Setting Root Directory Posted on: 07/27/2006 21:18:00

I got around this problem by creating an application on IIS on the subdirectory that contains album.ashx - it seems the handler assumes it's in the root directory of the application. Would love to learn the code, but don't have time!

Post edited by mzirino on 07/27/2006 21:18:26


User Posts:
Setting Root Directory Posted on: 08/26/2006 05:55:30

as I am not the web administrator of my hosted website (I cannot create an application on IIS), but liked the Album solution, I tried to develop a solution to the problem.

I (roughly?) solved the problem by modifying and adding few lines of code. The source files impacted are: "album.ashx" and "Default.aspx".

After making the changes below, just drop the files "album.ashx", "Default.aspx" and "Album.css" in any subdirectory to start enjoying the Photo Album from that subdirectory.

I didn't test the solution thoroughly, there might be some cache file names collisions or other bugs, but for the moment it satisfies my needs.

Find also the archive with the below changes at

Daniel Giabbai

Changes in "album.ashx", property "Album.HandlerUrl": changed lines 1337 and 1340:

public string HandlerUrl {
get {
string s = ViewState["HandlerUrl"] as string;
return (s == null) ? Page.ResolveUrl(Page.AppRelativeVirtualPath) : s; //"~/album.ashx" : s;
set {
ViewState["HandlerUrl"] = Page.ResolveUrl(value);

Changes in "album.ashx", method "Album.OnInit": added before and changed lines 1791 and 1792:

protected override void OnInit(EventArgs e) {
_isControl = true;
_filePath = Page.ResolveUrl(HandlerUrl);
_requestPathPrefix = _filePath.Substring(0, _filePath.LastIndexOf('/') + 1).ToLower();

string tmp = Page.ResolveUrl(Page.AppRelativeVirtualPath).Substring(0,Page.ResolveUrl(Page.AppRelativeVirtualPath).LastIndexOf('/'));
tmp = (tmp=="")?"/":tmp;

requestDir = (requestPathPrefix == tmp) ?
tmp :
_requestPathPrefix.Substring(0, _requestPathPrefix.Length - 1);

Changes in "Default.aspx", @Register directive: changed "Src" parameter:

<%@ Register Src="album.ashx" TagPrefix="photo" TagName="album" %>

Changes in "Default.aspx", "photo:album" tag: added "HandlerUrl" parameter:

<photo:album runat="server" ID="Album1" HandlerUrl="album.ashx" />
Post edited by DGiabbai on 08/26/2006 05:57:58


User Posts:
Setting Root Directory Posted on: 08/28/2006 11:38:09

Thanks for the code. I'll try to include a fix that doesn't require an additional property in the next release, if at all possible.