views:

43

answers:

1

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?

+1  A: 

It looks like IIS is denying you access to the actual folder.

By default Routing is supposed to honor the file system. Though this can be turned off.

ggonsalv
How do you turn it off, it is it a setting in IIS or the web.config?
Austin
http://msdn.microsoft.com/en-us/library/cc668201.aspx has Routing documentation. Here is the specific link for that feature http://msdn.microsoft.com/en-us/library/system.web.routing.routecollection.routeexistingfiles.aspx
ggonsalv
Okay, that was what I was looking for. I just had to Ignore some routes to keep the system from processing my .aspx files on disk. If anyone else needs them, I used routes.Ignore("{*allaspx}", new { allaspx = @".*\.aspx(/.*)?" });from Phil Haack's post: http://haacked.com/archive/2008/07/14/make-routing-ignore-requests-for-a-file-extension.aspx
Austin