asp.netwebformssystem.web.routing

Using Routing in Asp.Net Webform Application


I am using System.Web.Routing in the Asp.Net Webform Application. I wrote the following route in the global.asax

routes.RouteExistingFiles = true; // I made true/false both, but none works

routes.Add("competition", new Route
            (
               "Test",
               new CustomRouteHandler("~/Test/WebForm1.aspx")
            ));

And the directory structure is the following:-

Application

|

|--- Test (Folder)

   |--- Webform1.aspx

When I write in the browser http://localhost:xxxx/Test/ (using Casini), the request is handle in the traditional manner not through the routes, and, it gives me the "Directory Listing -- /test/" page.

Could you please help me out?


Solution

  • I had the same problem, and I chose the pragmatic solution that the file that should handle the default path is called Default.aspx

    routes.Add("competition", new Route ( "Test", new CustomRouteHandler("~/Test/Default.aspx") ));