Get nice looking directory listings for your IIS website with DirectoryListingModule

*************************************************
Update - 4/26/08:
IconHandler 2.0 released. Use IconHandler to build your own directory listing,
or any other app that needs file icons.

************************************************** 

Do you hate bland directory listing pages that most web servers have these days?  The Internet has gone through many evolutions, yet web directory listings somehow got left out to the point where sometimes they appear to predate the http protocol itself (gopher, anyone?).  Here is the default IIS7 directory listing:


Almost two years ago, this exact emotion led Bill Staples to write a sample directory listing module for our first set of early IIS7 demos.  This module read the directory contents of a url, and generated a nice-looking gallery view of the images in that directory.  It was a much needed improvement!

Since then, several other people on the team modified and re-wrote the module, adding visual bells and whistles and otherwise changing the way it looked.  Everyone thought it looked best their way.  The module grew and grew into a mess of c# code and HTML fragments, to the point where noone ever wanted to show the code for it, just how cool it made the site look.  For fun, here is a code excerpt from the original module:

                //write out links to paths leading up to directory

                Response.Write("<h3>g a l l e r y : ");

                    for (int i = 0; i<strpaths.Length-1;i++) {

                        strURL = strURL + strpathsIdea ;

                        Response.Write("<a href=\"" + strURL + "/" + "\">" + strpathsIdea + "/" + "</a>");

                        strURL = strURL + "/";

                    }

                Response.Write("</h3>\n");

I've always wanted to take the module, and rewrite it so that it provided complete separation of the module infrastructure / directory reading code, and the actual HTML content.  This way, a designer could go in and change the layout and the look and feel of the directory listing without having to change the code itself ... And since I try to stay away from actual website design as much as possible, this would give me all the pleasure of writing some server code and none of the pain of trying to make it look good.  That's the designer's job!

With that in mind, I wrote this directory listing module that uses an ASPX page as a template for generating the actual output, so the look and feel is entirely in the designers control.  The module simply provides the directory listing as a bindable collection of directory entries, each of which contains useful properties that can be used inside the the page to generate the UI.

In a nutshell, here is what the module does:

  1. Intercepts requests to "directory" urls within your application, like "http://example.com/files/"
  2. Reads the directory contents, and creates a collection of DirectoryListingEntry objects
  3. Stores this collection inside the HttpContext.Items collection
  4. Executes the configured template page, which databinds to the directory listing collection and produces the desired UI for your custom directory listing
  5. Hardcodes Absolutely No HTML content in the module ...

The sample page I wrote has a DataList control that I databind to the collection inside Page_Load():

void Page_Load()

{  

    DirectoryListingEntryCollection listing =         

Context.Items[DirectoryListingModule.DirectoryListingContextKey] as DirectoryListingEntryCollection;

   

    DirectoryListing.DataSource = listing;

    DirectoryListing.DataBind();

}

 

<asp:DataList id="DirectoryListing" runat="server">

    <ItemTemplate>

        <a href="<%# ((DirectoryListingEntry)Container.DataItem).VirtualPath  %>"><%# ((DirectoryListingEntry)

        Container.DataItem).Filename %></a>

    </ItemTemplate>

</asp:DataList>

On top of this, I threw in some sorting capabilities (The DirectoryListingEntry object provides a number of IComparer delegates that can be used to sort the collection on date modified, file size, and file name, but you can of course implement your own), and nice looking file icons using the IconHandler.  With minimal HTML design, here is what I got:

I want it!

You can view this app running live on my server here: http://mvolo.com/directorylisting/ (since I dont have VS installed on the server, ASPX shows with text icons). 

Download the sample app containing both the DirectoryListingModule, my simple template, and the IconHandler. 

Installation instructions:

  1. IIS7: Create an application, and unzip the contents of the app into its root directory.  That's it!
  2. IIS6: Create an application, and configure ASP.NET 2.0 to be a wildcard mapping for it.  Then unzip the contents of the app into the root directory of your application, and you are good to go.

What else is there to do?

Right now, the module is only aware of the physical file system directory structure for the directory you are viewing.  So, if your directory has a virtual subdirectory that maps to a physical location somewhere else, it won't show up in the directory list.  For example, if your application http://example.com/myapp has a root in c:\myapp, and you have a virtual directory http://example.com/myapp/files that points to c:\files, you are not going to see "files" in the directory listing for /myapp.  To fix this, the directory listing module needs to be Virtual Path Provider aware, which will also have a bonus in being able to provide directory listings of sharepoint sites.  This is coming soon ...

Also, since I am sure you are a better designer then me, if you end up making a cool directory listing template you want to share, please post it here.  If you make the coolest one, there may even be a prize involved ...

Published 21 January 07 01:35 by Mike Volodarsky
Attachment(s): mvolo-directorylisting-web.zip

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Jason said on January 21, 2007 2:12 PM:
That is really cool! I am bored and snowed in today and played with this a bit. I love it. Thanks!
# Fred said on January 23, 2007 5:07 PM:

Thanks!  That's really cool... but without the source for these things I can't use them... can't really base a production system on random unsupported DLLs downloaded from blogs.  So throwing the source up with the samples would be very much appreciated, otherwise it's just something that's cool but that i'll have to re-implement before I can think about using it for anything...

# Dominick said on January 24, 2007 3:10 AM:
Hi Mike, very nice! Maybe you should also check if directory browsing is enabled before you show the listing... cheers, dominick
# Mike Volodarsky said on January 24, 2007 10:13 AM:

Good point, Dominick - allowing directory browing on the server by default is generally not a good idea.

The module actually comes with its own configuration section, which has an enabled attribute just like the built in directory browing feature.  The default value for this attribute is false, so you have to explicitly enable it for the directories for which you'd like to allow browsing.

# DrPizza said on February 7, 2007 9:43 AM:
This would really be much better if you published the source. That's the interesting bit...
# RvdH said on February 9, 2007 1:43 PM:

Hi mike, nice module...

While trying it i stumbled on a issue, somehow all shows exactly as yours minus the icons, what do i do wrong?

Have to admit these is one of my first .net application installations i try so it can easily be a configuration issue.does the /bin folder need special read permissions?

# Mike Volodarsky said on February 9, 2007 5:38 PM:

RvdH,

Try making a request directly to your handler, /geticon.axd?file=.txt, and see if you are getting the text icon or not.  If you dont, check your web.config file to make sure it has both the icon handler registered in <modules> AND the iconhandler configuration section declared at the top of the file.  Download and consult the IconHandler sample application for reference.

When making a request directly to iconhandler, if you get a 404, that probably means the handler is not installed, and if you get a 500, it most probably means you have some configuration wrong or missing, and it should give you the details (be sure to have custom errors turned off or test on a local server to get the error details).

# RvdH said on February 11, 2007 12:40 AM:

Got it working now, at first i got a 404 error.

After turning custom errors off and restarting it somehow worked.

Mike, maybe it would be valuable to add a feature so one can choose the /root directory he/she likes to share, additional benefit would be that the script /bin & config itself can not be accessed/viewed/opened directly (or does it have such feature?)

# Robert said on February 20, 2007 12:01 PM:
I'm having trouble getting to this to work on IIS6. When i add the asp.net wildcard mapping, the iconhandler doesnt work. Going to /geticon.axd?file=.txt returns a 404 error. If I then remove the wildcard mapping, /geticon.axd?file=.txt returns the text icon as it should. But then of course the directorylisting component doesn't work. I'm using the exact web.config file from the download and correct files are in the bin directory. What would cause this?
# Robert said on February 20, 2007 10:00 PM:
If someone else experiences this...make sure when adding the wild card mapping that the "Verify file exists" checkbox is NOT checked. That was what was causing an issue for me. It defaults to checked.
# Mike Volodarsky said on February 21, 2007 1:26 AM:

RvdH,

You can always control which root directories you would like to share, by specifying a web.config in them (or a location tag in a top level web.config) that contains the configuration for the directory browsing module turning it on or off.

The /BIN directory of your application is automatically protected, preventing access of files within it over the web.  This protection is provided by an ASP.NET filter (and in IIS7, by configuration for the request filtering feature's protected namespaces).

# Arni said on March 8, 2007 7:57 AM:
Is there a way to call up the date modified in the list?
# Mike Volodarsky said on March 8, 2007 9:55 AM:

Arni,

Look in the template page - you can databind to any property of the DirectoryListingEntry object, or access the underlying FileInfo object and get any file information from that as well.

Thanks,

Mike

# RvdH said on March 13, 2007 9:06 AM:

Mike,

Huh?

Don't get it... i know the /bin & webconfig are protected by default, i just dont want it to display those and the dirlisting.aspx itself...

Take your demo posted here: http://mvolo.com/directorylisting/

Now lets say with exactly the same config i only wan't to share & display contents of the \content\ directory in it.

Can you post example? (I'm very new to asp.net)

# Mike Volodarsky said on March 13, 2007 4:36 PM:

RvdH,

I see what you are asking.  There is no way to exclusions right now, although that won't be so hard to add.  Today, the directory listing will display all physical folders in the directory being viewed.

I could add a configuration section that allows you to list the subdirectories / files, or regular expressions, to exclude from display.

Thanks,

Mike

# EHRETic said on May 10, 2007 9:40 AM:
Can't get this thing working on IIS6 ! Can somebody provide a guide for IIS "newbies" ? What I tried : - virtual directory under default site pointing on "D:\Web Sites\files" where the downloaded files are located - Created an application with a wildcard on "directoryListing.dll" (and I tried also to add Shelliconhandlerr.dll & ASP.net) - tried every possibility with read, write, directory browsing, etc... options (also execute permissions) Mike, can you please put more information about configuration, maybe I'm doing this completelly wrong ! Thanks in advance
# aye caramba! said on May 14, 2007 12:09 PM:
I've tried unzipping it into root of two websites on two IIS7 servers--both with application pools set to asp.net 2.0 and integrated pipeline. I'm getting interesting results so far. The IIS 7 longhorn beta server just serves up this error with no details: 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. The IIS7 Vista client machine gives me an "internet explorer cannot display the webpage" error in browser and a pop-up saying, "IIS Worker Process stopped working and was closed." (Data Execution Prevention shut the w3wp.exe down.)
# Mike Volodarsky said on May 15, 2007 12:46 PM:
EHRETic, Follow the instructions for setting up ASP.NET 2.0 as a wildcard mapping on IIS6, that are given in the LeachGuard post linked above - http://mvolo.com/blogs/serverside/archive/2006/11/10/Stopping-hot_2D00_linking-with-IIS-and-ASP.NET.aspx. You have to map aspnet_isapi.dll to be the wildcard, not any of the asemblies in the application. Good luck, Mike
# Mike Volodarsky said on May 15, 2007 12:49 PM:

Aye Caramba,

Can you paste the contents of the "application" event log message on the Vista machine corresponding to the worker process crash?  This is completely unexpected.

On the IIS7 beta3 server, be sure to turn off IE's friendly error messages in Tools > Options > Advanced tab, to get to the actual contents of the error.  If you are browsing from localhost, you will get the detailed error, if not, you may need to turn off IIS custom errors to get the error details.

Send me both and I'll take a look.

Thanks,

Mike

# Satchey said on May 16, 2007 3:34 AM:
I get this error when opening the page dirlisting.aspx "This type of page is not served". i'm using a IIS6 and have put in the wild card mappings and clicked off "verify that file exists". Does it work in IIS6
# Mike Volodarsky said on May 16, 2007 8:42 PM:
Satchey, It definitely works in IIS6. You dont request dirlisting.aspx directly - this page is the template that you edit to provide the directory listing views for your directories, for example when you request http://yourserver/somedirectory/. If someone requests the dirlisting.aspx page, they will get back an error response as is. What happens when you request a directory in your application?
# EHRETic said on May 22, 2007 6:57 AM:
Hello again, I've tried what was explained whith the wildcard, but I'm getting the same error as Satchey. I installed that on a brand new site with "standard" configuration. The problem is, you never explain what is the real standard configuration. You have a lot of configuration settings in IIS and if you change one, it will not work. It can be good to add a screenshot of every configuration steps with : - folder authorizations (script source access/read/write/directory browsing options) - execute permission (none/scripts only/scripts and executables) - in documents : if "enable default content page" is activated or not, and if yes, which documents. Like I said, for an IIS newbie, there is lot of combination to test ! ;O) Can you help ?
# Mike Volodarsky said on May 22, 2007 7:32 AM:

EHRETic, It is impossible to describe every possible setting and combination when giving these instructions - so I try to describe only the settings that are relevant to getting things working. I also try to minimize dependencies on other configuration options by designing the modules to be more robust in the face of differently configured servers.

Most of the time, other settings (for example, your default document setting) are not relevant.

If you have followed the wildcard instructions in the other post to set up ASPNET_ISAPI.dll to be a wildcard extension with file exists cleared, and you have ASP.NET installed, you should be operational.

Assuming you have the application in the default web site, what happens when you make a request to http://localhost/ ? Can you email me the response you get?

 Thanks, Mike

# aye caramba! said on June 1, 2007 12:17 PM:
Thanks for being willing to check into that for me, Mike. I had my hosting company move the site i was hoping to use your cool stuff on from the iis6 server to an iis7 server in the hope that it'd simplify things. I'm not sure if they're going to let me have a copy of the evt log(s) but will try. I can also try it on a vista workstation I've got.
# aye caramba! said on June 1, 2007 12:21 PM:
Thanks for being willing to check into that for me, Mike. I had my hosting company move the site i was hoping to use your cool stuff on from the iis6 server to an iis7 server in the hope that it'd simplify things. I'm not sure if they're going to let me have a copy of the evt log(s) but will try.
# Bam said on June 15, 2007 8:54 AM:
I can't get this working on IIS7 at all. I get the "This type of page is not served.". I am very ASPNET savy and can't figure out why this doesn't work. I'm not sure this works on the release version of Vista. Has anyone tried it? TIA Bam
# Mike Volodarsky said on June 17, 2007 9:34 AM:

Bam,

Please re-download the package - there was a silly bug that prevented it from working on Vista RTM.  It should be fixed now.

Let me know if you continue having issues.

Thanks,

Mike

# Alex said on June 24, 2007 9:03 PM:
Hi Mike, Thanks for the app. Tried it on Vista Ultimate. Had to remove system.web section of web.config, otherwise IIS complains that for app pool modules/handles should not be defined there. Anyway it seems it works except it doesn't provide the icons. If I manually request http://.../geticon.axd?file=.ppt&size=small it does work fine. If I rclick on the broken image I see "http://geticon.axd/?file=.jpg" URL, so it just doesn't point to the app somehow. Could you help, please. Thanks!
# Alex said on June 24, 2007 9:49 PM:
Mike, Managed to make it work just by removing slash between AppDomainAppVirtualPath and geticon.axd. Looks nice. It would be really powerful if you can provide a regEx filtering via web.config or at least just a simple list of file extensions to ignore, otherwise it is so much rubbish including hidden files and web.configs in those directories...
# LaMpiR said on July 3, 2007 2:24 PM:
HI Mike. I've freshly installed IIS6 on my XP because i don't like vista. I used .net framework 2.0 but i couldn't open any application, i was getting error "Server Application Unavailable..." but when i switched to 1.1 i got nothing. When i go to /localhost/dir/ -- this is just test directory i get standard listing. I have moved all the files here which where in .zip. When i go to http://localhost/dir/? i get same default look. If you could leave your mail i vil send you everything you wish. Also, i would like to point out that this is my first contact with asp.net and IIS6. Best Regards, Srdjan
# Jaggie said on August 3, 2007 5:16 AM:
Mike, Thanks for a great piece of code... It works a dream. Unfortunately the reason i arrived at your site was to find some way of enumerating a file system - taking into account NTFS permissions. Normal directory browsing obviosuly covers this but with your modification it seems that this isn't possible.... Am I getting confused or is this the case??? If so can you recommend anything? Thanks again though, I will be using it in other places! Kind Regards John Gerhardt
# Mike Volodarsky said on August 3, 2007 11:40 PM:

LaMpiR,

XP has IIS 5.1.  This is not supported for IIS5.1, only IIS6 (W2k3) and IIS7+(Vista/Longhorn), as specified in the post installation instructions.

Thanks,

Mike

# Mike Volodarsky said on August 3, 2007 11:43 PM:

Jaggie,

Can you elaborate on what you are tryng to accomplish?  Do you want to display the ACL string on the files, or do you want to filter the files out that the currently authenticated user doesnt have the right to read, etc?

Keep in mind that the template databinds to the file collection stored in the request context, but nothing stops you from writing more code in the template to go through that collection, access each file, and filter it based on whether the ACLs in that file allow access to the current user.  Likewise, if you just want to display additional information, edit the template to access that information for each file and display it.

In either case, let me know more specifically what you are looking for and maybe it will make sense to add to DirectoryListingModule v2.0 :)

Thanks,

Mike

# Otto said on September 5, 2007 10:52 AM:

hi,

this is exactly what i need.

however im a nono with IIS 6

i dowloaded the files and copied it in my virtal directory.

unfortunateky i get an runtime error.

IIS6: Create an application, and configure ASP.NET 2.0 to be a wildcard mapping for it.  Then unzip the contents of the app into the root directory of your application, and you are good to go.

sorry but what is creating an apllication?

amd ho to do the wildcard mapping?

thanks for the help

# DJX said on September 25, 2007 2:53 PM:
Yeah, I also get a runtime error on the client side and a configuration error on the server side with this info: Parser Error Message: Could not load type 'Mvolo.ShellIcons.Web.ShellIconHandler'. Line 29: Line 30: Line 31: Line 32: Line 33: I just copied and pasted the contents from the archive into a directory and I even added wildcard mappings. When I comment out the part that is causing the problem in the web.config file I get an error from the actual .aspx file. I am totaly new to asp.net and know nothing of web.config and stuff like that. Any help? Thanks.
# DJX said on September 25, 2007 3:38 PM:
Never mind! I got It! All I had to do is allow Script And Executables execute permission! Great!
# DJX said on September 26, 2007 5:24 PM:
Great app.... Does not work with folders that have dots or other similar characters in them. Should grab the icon from the file rather then a database sort of thing. Because I have some missing icons becuase of that. Other wise all is good!
# Jim Hanifen said on September 27, 2007 4:22 PM:
I love this...but really need it to work with virtual directory's also. Any luck on that? Thanks again
# humberto said on October 2, 2007 6:21 PM:
Will this directory code work with IIS 5.1? Thanks and nice job! Humberto
# Keith said on October 2, 2007 6:32 PM:
Mike thanks for the code. My icons weren't showing up either until I removed the code: <%=HttpRuntime.AppDomainAppVirtualPath %> from dirlisting.aspx. For some reason that wasn't being populated with the appropriate server url. I am currently trying to figure out how to get it to integrate into my asp.net app as a subfolder and not show the files that make it work. I'm glad you and your chronies at MSFT are fixing up the directory browsing cosmetics in IIS7. Its a welcome change.
# Mike Volodarsky said on October 6, 2007 2:33 AM:

DJX,

You can configure the handler to use the full filename to determine the icon, instead of the extension.  You may need to change the template to make sure it passes the entire filename as well.

The handler does use the win32 shell icon API, not a database.

Thanks,

Mike

# Mike Volodarsky said on October 6, 2007 2:35 AM:

Jim,

The module does list the contents of virtual directories, but must be installed at the application level (like any ASP.NET module).

If you are asking for the ability to show virtual sub-directories in addition to the physical subdirectories in the listing, that will have to come in v2.0.  

No ETA right now, but I'd like to get to it soon, and when I do, this is one of the first things on my list :)

Thanks,

Mike

# Mike Volodarsky said on October 6, 2007 2:36 AM:

humberto,

This wont work on IIS 5.1.  You have to use IIS6 for the wildcard mapping configuration, or IIS7 for optimal operation without the wildcard.

Thanks,

Mike

# Mike Volodarsky said on October 6, 2007 2:38 AM:

Hi Keith,

If you find the existing template doesn't work for you, can you share yours? I'd like for anyone who has a cool template to contribute it so I can eventually host a couple sample templates for people to get.

I put together the current template very quickly, so its definitely not foolproof.

Thanks,

Mike

# Craig said on October 11, 2007 9:24 AM:
I must have missed something or am completley green at this. probobly both. If I create an application for IIS 6.0 .asa it tells me the files already exists.
# Otto said on October 13, 2007 11:01 AM:
when a file is overwritten by a file with same name the new details arent showed (not correctly sorted by new date) refreshing doesnt help thanks
# DJX said on October 16, 2007 10:45 PM:
First off, I'm getting some runtime errors releated to ASP.net but I think it's my fault. Something about: FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)]. Any one else having a problem like this? Also, I configured the app (web.config) to "alwaysUseExtension="false" in hopes that the app would not give me errors when I try to open a folder or file that has a dot or other wild characters in it but that still doesn't work. Any suggestions? I'm glad you're still develping this app. Keep up the great work.
# CArl Valiulis said on October 17, 2007 1:28 PM:
Have you got this to work within a Virtual directory yet
# LVM said on October 23, 2007 10:29 AM:

Hi Mike,

I want to open the index.htm or any other file when I enter this directory. It has worked before I started to use your application. Please tell me how to tell the IIS to open desired file, when I enter the page. Thank you in advance

# Another Mike said on October 24, 2007 2:39 PM:

Trying to install this with IIS6. Not an ASP.NET person. Once I add the aspnet_isapi.dll file as a wildcard, the web site only returns 404 errors - even after I remove the wildcard, it still returns 404's and I need to recreate the web site.

Doing this on a pretty vanilla config - from scratch.

The server has ASP.Net framework 2 AND 3 - if that matters...

# Mike Volodarsky said on October 25, 2007 11:02 AM:

Another Mike,

There shouldn't be a reason why, after removing the wildcard, you would get 404 errors if you werent getting them before adding the wildcard.  Are you changing anything else?

What is the 404 error's substatus?  Is the error coming from ASP.NET, and if so, what is the callstack (you can find it in the "source" of the error page at the bottom).

Thanks,

Mike

# DJX said on October 26, 2007 11:00 AM:
I was trying to get some explanation and background behind this error: FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)]. I cannot find much but I am now starting to beleive this is a problem with the module (app). This Runtime error happens randomly, when browsing through the directories. I really think, now doing some research and asking other people, that this is a bug with the module. Any help or acknowledgement?
# DJX said on October 26, 2007 10:21 PM:
I think I fixed my Runtime error... The problem looks to be a permission problem with virtual directories. When I made virtual directories for the content on my site, I never granted those VD: "Script and Execute Access". Since I have enabled that on my virtual directories, under my content, I have not received the dreaded: FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)] That my users hated so much (I did too)... So, in closing, I think I fixed it but it's still undergoing testing. I'll be sure to update back here if did not solve my problem. Now, if only I could figure out how to get files and folders with dots and other wild characters in their names to be servered through this module...I'd be set!
# DJX said on October 26, 2007 10:40 PM:
Funny...as soon as I post a comment here saying I think I've fixed it, the dang thing pops up again! FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)] This has to be a fault in the module. I've tried everything now... Sorry for all the posts but it seems to be the only way to communicate for support of this App.
# Aim said on October 27, 2007 5:27 PM:
Hi, great application, simple and working. I have found a bug: when a directory name contains "." (a dot), than the icon of the directory is wrong. It seems like the handler that generates icons thinks that it is a file when the name passed contains ".". Could you please fix this and let me know by email? Good job anyway. Cheers Aim
# Mike Volodarsky said on October 27, 2007 9:52 PM:

DJX, I've never seen that exception.  Can you provide the full stack trace?

DJX/Aim, thanks for letting me know about the .'s - I've heard others report the same issue.  I'll be fixing this soon!

Thanks,

Mike

# Mike Volodarsky's ServerSide said on October 28, 2007 3:02 AM:

Over the past several year, I&#39;ve written quite a few modules for IIS7 / ASP.NET. Some of these were

# DJX said on October 28, 2007 7:26 PM:
Full Stack Trace: [FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)] System.Web.Configuration.RegexWorker..cctor() +0 [TypeInitializationException: The type initializer for 'System.Web.Configuration.RegexWorker' threw an exception.] System.Web.Configuration.RegexWorker.Lookup(String from) +0 System.Web.Configuration.BrowserCapabilitiesFactory.MozillaProcess(NameValueCollection headers, HttpBrowserCapabilities browserCaps) +475 System.Web.Configuration.BrowserCapabilitiesFactory.DefaultProcess(NameValueCollection headers, HttpBrowserCapabilities browserCaps) +3150 System.Web.Configuration.BrowserCapabilitiesFactory.ConfigureBrowserCapabilities(NameValueCollection headers, HttpBrowserCapabilities browserCaps) +20 System.Web.Configuration.BrowserCapabilitiesFactoryBase.GetHttpBrowserCapabilities(HttpRequest request) +159 System.Web.Configuration.HttpCapabilitiesEvaluator.EvaluateFinal(HttpRequest request, Boolean onlyEvaluateUserAgent) +23 System.Web.Configuration.HttpCapabilitiesEvaluator.Evaluate(HttpRequest request) +182 System.Web.Configuration.HttpCapabilitiesBase.GetBrowserCapabilities(HttpRequest request) +162 System.Web.HttpRequest.get_Browser() +134 System.Web.ErrorFormatter.RequiresAdaptiveErrorReporting(HttpContext context) +104
# LVM said on October 30, 2007 3:23 AM:

Mike,

please tell me what to do to have the possibility to load desired page in one of the subdirectories under the main directory where your programm is working.

Thank you in advance for your help

# DJX said on November 5, 2007 11:46 AM:
Will this module work with Windows Server x64 Editions?
# DJX said on December 4, 2007 9:28 PM:
With the install of the lastest Microsft Update: Microsoft .NET Framework 2.0 Service Pack 1 (KB110806), This application seems to be faulting with error event 1002 and HTTPERR: geticon.axd?file= - 1 Connection_Abandoned_By_AppPool. It does this so many times that it crashes my whole app pool and my site becomes unusable (Service Unavaliable) untill I manually restart the app pool. I think the problem is with the Icon Handler but could have something to do with the dir listings module as well. I'm using Windows Server 2003 R2 Enterprise x64 (SP2) with Microsoft .NET Framework 2.0 Service Pack 1 (KB110806) (x64).
# Jason said on January 18, 2008 9:41 AM:
I am trying to figure out how I would modify the sorting. Right now that sample code sorts so that if you sort by date the oldest files are on top. What if I wanted it to sort the newest at the top? Also one other thing, How would I get the modified date in right next to each file?
# romd said on February 5, 2008 9:38 AM:
Hey mike, looks really great. if this works on our server... it'll save me a lot of time yet can't deny we're still getting a lot of problems: Parser Error Message: Could not load type 'Mvolo.DirectoryListing.DirectoryListingModule'. (C:\Inetpub\wwwroot\DierctoryLister\web.config line 29) gave it code access permissions and everything, but still nothing. Could you list a more detailed steps to install it? more screen shots would be great. me using Win2003 IIS6 thanks,
# Rolf Szimnau said on February 5, 2008 10:53 AM:
Hello Mike, First of all thanks for making this available. I have deployed the solution on a windows 2003 server, but i run into a problem that the icons are not showing when accessing the web page.But when i change the URL by adding "/geticon.axd?file=.bmp" - i get the image fine. Do you have a explanation why it does not pull in the icons in the main folder? Thanks
# DotNetKicks.com said on March 18, 2008 12:18 PM:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# MVolo's Blog said on April 27, 2008 2:57 AM:

Since its release, IconHandler has been a pretty popular module (on its own and with the custom DirectoryListingModule

# Ramesh Janjyam said on May 2, 2008 7:35 AM:
Can you please tell me, How can I configure directory browsing only to a particular directory in my application using your module.
# Mike Volodarsky said on May 2, 2008 11:54 AM:

Hi Ramesh,

See an earlier comment that explains how to do it. In a nutshell, set <directoryListing enabled="true" /> in any virtual directory you'd like to serve directory listings in.

Note that while you can control which directory the directory listing is enabled for, you have to replace the built-in directory listing on an application basis - can't have built-in directory listings for one vdir and the custom ones for another vdir in the same app.

Thanks,

Mike

# John Doe said on May 20, 2008 9:05 AM:
is it possible to get this thing to look like apache?
# Tony said on May 28, 2008 8:14 AM:
How can I eliminate certain file types and directories from the listing?
# Jiriki said on May 29, 2008 1:21 AM:
To add Last Modifed, add the following function to the dirlisting.aspx: String GetFileDateString(FileSystemInfo info) { if (info is FileInfo) { return String.Format("- {0}", (DateTime)(((FileInfo)info).LastWriteTime)); } else { return String.Empty; } } then add to the following right after the call for the file size:  <%# GetFileDateString(((DirectoryListingEntry)Container.DataItem).FileSystemInfo) %>
# Jiriki said on May 29, 2008 1:37 AM:
For a list of other attributes and their "syntax" you can list see: http://msdn.microsoft.com/en-us/library/system.io.fileinfo_properties.aspx
# Pete said on June 9, 2008 5:25 PM:
I'm still having problems with the icon. I've tried the changes in the dirlisting.aspx (removing the slash) I also verfied the URL is being passed in (i.e. for zip i see geticon.axd?file=.zip Any ideas?
# Renegade said on June 16, 2008 1:42 PM:
Hi is there anyway to set it up that the web.config, bin folder and dislisting.aspx are hidden/ not showen?
# Renegade said on June 17, 2008 8:36 PM:
Pete make sure you have the latest versions on the iconhanlder dll files in you bin folder. I had the same problem. I updated the files and that seemed to have solved my issue. I didnt have to remove the slash
# Sleeper said on June 26, 2008 6:04 AM:
Nice. work, Can some one help me to change the font size so it's clear on a 720p TV ??? I can't code
# cnblogs.com said on July 1, 2008 10:10 PM:

1. ASP.NET Popup Control http://www.codeproject.com/KB/custom-controls/asppopup.aspx 2. Componentart

# wade walker said on July 3, 2008 3:53 PM:

I keep getting, 'This page cannot be used without the DirectoryListing module'. I followed your instructions. I'm on Vista...

# Mike Volodarsky said on July 4, 2008 12:04 PM:
Hi Wade, If you request the template page directly, thats what you'll get. Try requesting the root of the directory, i.e. http://localhost/, NOT http://localhost/directorylisting.aspx. If you still get that error, let me know. Thanks, Mike
# Alina said on July 16, 2008 2:20 PM:
Any updates on being able to hide file types or directories from being listed? This application is great, but eventhough I have a default document set for the directory where it is installed it still shows the list of files rather than the default page. Am I doing something wrong or is this how it is meant to work due to the configuration ()in the web.config file?
# RJG said on July 21, 2008 4:27 PM:
It would be nice if i could see the example you posted here: http://mvolo.com/directorylisting/ I get 404 error. :(
# Nathan said on August 13, 2008 1:47 PM:
I'm having a problem with this on iis6. I keep getting the error "Server Application Unavailable". Could someone provide a checklist of what to look for. Many thanks

Leave a Comment

(required) 
(optional)
(required) 
Enter the code you see below


About Mike Volodarsky

For the past 5 years, I was the core Program Manager for Microsoft ASP.NET 2.0 and IIS 7.0 products. I drove the design and development of the IIS 7.0 web server core, the IIS FastCGI support, the AppCmd command line tool, the ASP.NET Integrated pipeline, and other special projects around server security, performance, and scalability. Now, I am working on my own on cutting edge web server tech on top of the Microsoft IIS platform, and continue blogging about it here.

About me



For the past 5 years, I was the core server Program Manager for the IIS 7.0 and ASP.NET 2.0 products at Microsoft.
Now, I work on advanced web server tech using IIS 7.0, .NET, and Windows Server 2008 and write about it in this blog.

View Michael Volodarsky's profile on LinkedIn

Writings



TechNet Magazine
>Top 10 Performance Improvements in IIS 7.0

MSDN Magazine
>IIS 7.0: Build Web Server Solutions with End-To-End Extensibility
>IIS 7.0: Enhance Your Apps with the Integrated ASP.NET Pipeline
>IIS 7.0: Explore The Web Server For Windows Vista And Beyond
>Design and Deploy Secure Web Apps with ASP.NET 2.0 and IIS 6.0
>Fast, Scalable, and Secure Session State Management for Your Web Applications


Tools and Modules

LeechGuard
IconHandler 2.0
DirectoryListing
HttpRedirection
IIS Auth for Wordpress
iisschema.exe
PortCheck.exe v2.0

Popular Posts

- ASP.NET 2.0 Breaking Changes on IIS 7.0
- Develop IIS7 modules and handlers with .NET
- Troubleshoot IIS7 errors like a pro
- Troubleshooting 503 / "service unavailable" errors
- Troubleshooting "server not found" errors
- Create IIS7 sites, applications, and virtual directories
- Run Ruby on Rails with IIS FastCGI
- VS Debugging of ASP.NET applications on Windows Vista
- Stop hot-linking with IIS and ASP.NET

Tags

Search

Go

This Blog

Archives

Good IIS Blogs

Disclaimer

These postings are provided as is with no warranties, and confer no rights. The views expressed in this blog are entirely my own.

Syndication