ASP.NET Routing - How to respond 404 for .aspx requests
I am using routing in webforms to clean up urls. I store all my .aspx
files in the /Pages directory and route to them with clean URLs. As it
stands I can still access these files by navigating to /Pages/Home.aspx
for example. How can I either throw a 404 or redirect to a different page
in my routing table? Here is what I have tried:
routes.RouteExistingFiles = true;
routes.Ignore("{resource}.aspx/{*pathInfo}");
routes.Ignore(@"*\.aspx");
routes.MapPageRoute("Home", "", "~/Pages/Home.aspx");
This isn't working at all, and I could use some advice.
No comments:
Post a Comment