SiteCrafting, Inc.

2 Mar

Mapping folders to Asp.net

If you need to have an extensionless URL map to ASP.net 2.0, here are three options.
  1. Add a Wildcard mapping in Internet Information Services for your website
  2. 3rd party software, such as ISAPI 2.7 or higher
  3. Redirect 404 errors to 404.aspx and use Global.asax to capture the URL that caused the 404 error
Example:
Have http://www.mywebsite.com/calendar/ map to http://www.mywebsite.com/calendar.aspx




Add Wildcard mapping

Wildcard mapping will result in all requests being forwarded to asp.net. Which includes.html, .htm, .css, .js, images, etc. This will result in a performance hit.
  • Start IIS
  • Right click on the Website, "Default Web Site" is a common name
  • Click Properties
  • Click Home Directory
  • Click Configuration
  • On Mappings tab click Add
    • Executable = link to the asp.net dll. Example: c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll
    • Extension = .*
    • Limit to: GET, POST

3rd party software, such ISAPI

You can install ISAPI and add a regular expression to redirect the url. The regular expression below will perform the redirect for the example at the top of this article.

ISAPI 2.7
RewriteRule ^/calendar/ calendar.aspx [I,R]

404 Errors

Update IIS to redirect 404 errors to 404.aspx.
Update the Global.asax file of your website. Add code to Application_BeginRequest that will capture the URL that caused the 404 error.

Global.asax sample

Read Serve extensionless URL without using ISAPI handler or wildcard mapping for a good explanation of this method.

Hopefully this helps!



ASP.NET 2.0, From the Workbench
by Ken Foubert | 3/2/2009 11:30am | Comments (3)

Great site. I like the way you explain everything without using complicated terms.

Left by Craft Fairs | Dec 24, 2009

Thanks a lot Craft Fairs.

Left by Ken Foubert | Dec 28, 2009

That's great, I never thought about Mapping folders to Asp.net like that before.

Left by traslochi internazionali milano | Dec 30, 2009

Leave a Comment




* required    Comment Guidelines