最常见的做法是在 global.asax.cs/vb
内的 Application_Start 事件中注册路由。文件。但是您需要有权访问此文件才能执行此操作。美好的。
我要么没有,要么不想。我正在尝试将 Asp.net MVC 应用程序集成到 Sharepoint 2010 站点中,并且不想创建我的自定义全局应用程序类,该类也会为我注册路由并更改 Sharepoint 的 Global.asax 文件并在其中放置不同的类定义它。我的申请不会被接受,因为我会对 Sharepoint 做不受支持的事情。
我想知道是否可以在其他地方注册路线?有两种选择首先出现在我的脑海中:
Note: Application-level events are not accessible in modules. Bummer. They can only access request-level events.
Important: ... or so I thought. If you check accepted answer it's actually possible to handle application-level start event. Indirectly and reliably it is possible.
有没有更好的方法/地方来注册路线?
最佳答案
也许这篇文章对你有用
http://haacked.com/archive/2010/01/17/editable-routes.aspx
您可以使用 HTTP 模块在 RouteTable.Routes RouteCollection 对象上设置路由。
关于asp.net-mvc - 将路线注册到 global.asax 的替代位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3342158/