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?

2 Answers 2

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") ));
Sign up to request clarification or add additional context in comments.

2 Comments

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

3 Comments

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 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.
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...
...if you set the default document in iis to WebForm1.aspx, it would serve that page, but maybe not desired in your app?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.