To better organise my ASP.Net project I placed all my .aspx files in a folder called WebPages.
I would like to find a way to mask out the 'WebPages' folder out from all my URLs. So for example, I do not want to use the following URLs:
http://localhost:7896/WebPages/index.aspx
http://localhost:7896/WebPages/Admin/security.aspx
But instead, would like all my URLs to be as follows ('WebPages' is a physical folder that I use for structuring my work, but should not be visible to the outside world):
http://localhost:7896/index.aspx
http://localhost:7896/admin/security.aspx
I was able to come up with a solution of my own by specifiying routing entries 'for every page' that I have in my project (and it works), but that is simply not maintainable going forward and I need another method.
public class Global : HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("", "index.aspx", "~/WebPages/index.aspx");
routes.MapPageRoute("", "admin/security.aspx", "~/WebPages/Admin/security.aspx");
}
}
Perhaps what I am after is a class that catches all requests, and simply appends my 'WebPages' physical directory?