简体   繁体   中英

How to configure IIS 6.0 to use both default content page and wildcard application maps

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?

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.

您必须添加将/请求映射到default.aspx的ASP.NET global.asax或HttpModule。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM