精简路由上下文信息格式,显示更多重要的信息,避免显示重复的信息 隔离静态路由到模块和运行时路由的模块的模块对象实例缓存 调整运行时路由到模块的API,使可以按需要调整路由片段信息,以显示更多信息 修正重定向路由不能重定向到网站根路径的问题 修改Mvc测试网站相关测试代码和说明
netwjx 编写于 2012-02-17 16:23:46
X
using System;
using System.Collections.Generic;
using System.Web;
using NewLife.Mvc;

/// <summary>
///TestController 的摘要说明
/// </summary>
public class TestController : GenericController, IController
{
    public TestController()
    {
        world = "world";
    }

    public override void Render(IDictionary<string, object> data)
    {
        Response.Write("Hello " + world + " ");
        Response.Write(Request.Url);
        Info();
    }

    public void Info()
    {
        IRouteContext c = RouteContext.Current;
        Response.Write("<pre>" + Server.HtmlEncode(string.Format(@"
NewLife.Mvc.RouteContext.Current.RoutePath : {0}
NewLife.Mvc.RouteContext.Current.Module : {1}
NewLife.Mvc.RouteContext.Current.Factory : {2}
NewLife.Mvc.RouteContext.Current.Controller : {3}
NewLife.Mvc.RouteContext.Current.Path : {4}
", c.RoutePath, c.Module ?? null, c.Factory ?? null, c.Controller ?? null, c.Path)) + "</pre>");
        Response.Write("<h4>完整路由上下文跟踪</h4>");
        Response.Write("<pre>" + c.ToString() + "</pre>");
    }

    private string _world;

    public string world
    {
        get { return _world; }
        set { _world = value; }
    }
}
public class TestController1 : TestController
{
    TestController1()
    {
        world = "第二个测试控制器";
    }
}

public class TestController2 : TestController
{
    TestController2()
    {
        world = "第三个控制器";
    }
}