tags:

views:

1322

answers:

3

In the filesystem I have

    /file.aspx
    /directory/default.aspx

I want to configure IIS so that it returns the appropriate file (add the aspx extension) or directory (default content page) as follows:

    /file -> /file.aspx
    /directory -> /directory/default.aspx 
    /directory/ -> /directory/default.aspx

I have configured the Wildcard application mapping set to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll. When the "Verify that file exists" is unchecked, the the file request works but not the directory request (returns 404). When the "Verify that file exists" is checked, the directory request works but not the file request.

How can I configure it so that both the file and directory requests will work?

A: 

You'll have to add an ASP.NET global.asax or HttpModule that maps the / request to default.aspx.

Mark S. Rasmussen
Could you provide a bit more detail?
g .
Look here for how to do this: http://urlrewriter.net/index.php/support/installation/windows-server-2003
Keltex
+1  A: 

I recommend using UrlRewriter:

http://urlrewriter.net/

This allows you to create all the mappings above that you desire. One thing that you'll have to do (if you're using IIS 6 or earlier) is configure IIS so that all extensions are handled by asp.net. The documentation explains how to do this. Then you create a bunch of rules in your web.config (or separate rewriter.config as I use) in the form of regular expressions to create your mappings.

Incidentally, for the above example, you probably don't need to do anything for the last two rules. IIS will take care of those automatically. For the first rule it will be something like:

<rewrite url="^/file$" to="/file.aspx" />

You could get more clever and write generalized rules so you don't have to write one rule per file.

Keltex
A: 

I looked at url rewriting, but ultimately decided on a simpler solution. I just moved the file.aspx into a directory and renamed it to default.aspx.

g .