1

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?

Jack
  • 10,943
  • 13
  • 50
  • 65
Zohaib
  • 496
  • 7
  • 21

2 Answers2

1

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") ));
Pete
  • 12,206
  • 8
  • 54
  • 70
  • Indeed, or use Default.aspx instead as suggested since its probably already in the defalt docuemtns list – Mark Redman Aug 20 '09 at 12:36
  • @Pete : The suggestions you provided work with me too. But, now the question is which http Module is executing this request, the traditional http Module (asp.net one ) or routing http modules (asp.net mvc)? Because, a/c to the rememdy, i think its using traditional http module (asp.net one). – Zohaib Aug 23 '09 at 04:48
0

Are you using Routing straight out the box for WebForms, I have just implemented this for "WebForms" specifically, since there is some things to be aware of:

http://haacked.com/archive/2008/03/11/using-routing-with-webforms.aspx

HTH

Update:

Using the implementation in the link still produces the same error, since the actual folder exists.

I would think that since the folder exists, it would be served (in some cases listing the folder contents may be desired)

Maybe taking a different approach would be better for instance, if the pages all point to specific extranet login pages maybe an extra descriptive folder would work, eg: /Extranets/Test/ ?

Mark Redman
  • 24,079
  • 20
  • 92
  • 147
  • Yes, i am using straight out of the box. All the other routes are working fine, such as routes.Add("competitionNew", new Route ( "NewTest", new CustomRouteHandler("~/Test/WebForm1.aspx") )); But, my real concern is, if the request is http://localhost:xxx/Test/ where Test is also the folder in the application, then it is showing the "Directory Listing -- /test/" page, not rendering the webform1 page. – Zohaib Aug 20 '09 at 11:42
  • ok, tested on my app (with WebForm routing as per link implemented) and ot appears to do the same thing, I have updated my answer... – Mark Redman Aug 20 '09 at 12:06
  • ...if you set the default document in iis to WebForm1.aspx, it would serve that page, but maybe not desired in your app? – Mark Redman Aug 20 '09 at 12:11