Using RouteExistingFiles to block access to existing files even if no route exists

Posted by Michael Stum on Stack Overflow See other posts from Stack Overflow or by Michael Stum
Published on 2010-03-28T09:49:58Z Indexed on 2010/03/28 9:53 UTC
Read the original article Hit count: 392

Filed under:
|
|

In ASP.net MVC 2, I can use routes.RouteExistingFiles = true; to send all requests through the routing system, even if they exist on the file system.

Usually, this ends up hitting the "{controller}/{action}/{id}" route and throws an exception as the controller cannot be found.

I do not want to use that route though (I have only a few URLs and they are specifically mapped), yet I would still like to prevent access to the file system.

Basically I want to Whitelist pages using IgnoreRoute. Is there a built-in way to do this? My current approach is to still have the "{controller}/{action}/{id}" route and generate a 404 when this is hit, but I'm just wondering if something is built-in already?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about ASP.NET