Is it possible to have a .NET route that maps to the same place as a directory?

Posted by Austin on Stack Overflow See other posts from Stack Overflow or by Austin
Published on 2010-04-30T20:09:26Z Indexed on 2010/04/30 21:07 UTC
Read the original article Hit count: 174

Filed under:
|
|
|

I'm building a CMS using WebForms on .NET 4.0 and have the following route that allows URLs like www.mysite.com/about to be mapped to the Page.aspx page, which looks up the dynamic content.

routes.MapPageRoute("page", "{name}", "~/Page.aspx");

The problem is that I have a couple of folders in my project that are interfering with possible URLs. For example, I have a folder called "blog" where I store pages related to handling blog functionality, but if someone creates a page for their site called "blog" then navigating to www.mysite.com/blog gets the following error:

403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied.

Other similar URLs route correctly, but I think because .NET is identifying /blog as a physical location on the server it is denying directory access. Is there a way to tell IIS / .NET to only look for physical files instead of files and folders?

© Stack Overflow or respective owner

Related posts about c#

Related posts about webforms