简体   繁体   中英

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?

我遇到了同样的问题,我选择了务实的解决方案,应该处理默认路径的文件称为Default.aspx。

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

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/ ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM