实现重定向的路由配置,方便在模块 网站 服务器间重定向
netwjx authored at 2011-12-15 17:33:06
838.00 B
X
using System;
using System.Collections.Generic;
using System.Web;
using NewLife.Mvc;

/// <summary>
///TestModuleRoute 的摘要说明
/// </summary>
public class TestModuleRoute : IRouteConfigModule
{
    public void Config(RouteConfigManager cfg)
    {
        cfg
            .Redirect("/redirect1$", "/foo")
            .Redirect("/redirect2$", "~/static.bmp")
            .Redirect("/redirect3$", "/", true)
            .Redirect("/redirect4$", delegate(RouteContext ctx, string routePath)
            {
                return "http://www.google.com/";
            })
            .Route<TestController>("/foo")
            .Route<TestController>("/foo$")
            .Route(
                "/f", typeof(TestFactory),
                "/foo2", "TestController",
                ""
            );
    }
}