views:

187

answers:

2

Hi,

I am using System.Web.Routing in the Asp.Net Webform Application. I write 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? I am looking forward to hear from you.

A: 

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
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
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
...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
+1  A: 

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
Indeed, or use Default.aspx instead as suggested since its probably already in the defalt docuemtns list
Mark Redman
@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