简体   繁体   English

在Asp.Net Webform应用程序中使用路由

[英]Using Routing in Asp.Net Webform Application

I am using System.Web.Routing in the Asp.Net Webform Application. 我在Asp.Net Webform应用程序中使用System.Web.Routing I wrote the following route in the global.asax 我在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. 当我在浏览器中使用http://localhost:xxxx/Test/编写(使用Casini)时,该请求以传统方式处理,而不是通过路由处理,因此,它显示了“目录列表-/ test /”页面。

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: 您是否正在直接使用WebForms的路由功能,我刚刚专门为“ WebForms”实现了此功能,因为有一些注意事项:

http://haacked.com/archive/2008/03/11/using-routing-with-webforms.aspx 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/ ? 例如,如果所有页面都指向特定的Extranet登录页面,则采取不同的方法可能会更好,例如,可以使用一个额外的描述性文件夹,例如:/ Extranets / Test /?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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