开发者

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

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜