如何注册已外面的Global.asax定义的路由 [英] How to register routes that have been defined outside Global.asax

查看:207
本文介绍了如何注册已外面的Global.asax定义的路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实施的<一个模式href=\"http://stackoverflow.com/questions/278668/is-it-possible-to-make-an-asp-net-mvc-route-based-on-a-subdomain\">introduced被这个问题

接受的答案提供了途径在哪里都在一个单独的类中定义的策略。我的问题是究竟如何调用从Global.asax中的code。

The accepted answer provides a strategy where routes have been defined in a separate class. The question I have is exactly how to call that code from Global.asax.

THX

推荐答案

请参见从同样的问题另外一个答案,或者更具体地说中,所提供的链接的回答。

See another answer from the same question, or more specifically the link provided in that answer.

所有你应该做的是 ExampleRoute 的一个实例,在Global.asax添加到 RouteCollection

All that you should have to do is add an instance of ExampleRoute to the RouteCollection in the global.asax.

    public static void RegisterRoutes(RouteCollection routes)
    {
        // ...other routes
        routes.Add(new ExampleRoute());
        // ...more routes
    }

这篇关于如何注册已外面的Global.asax定义的路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆