日期:2014-05-17 浏览次数:20510 次
RouteValueDictionary defaults = new RouteValueDictionary();
RouteValueDictionary constraints = new RouteValueDictionary();
RouteValueDictionary tokens = new RouteValueDictionary();
defaults.Add("controller", "home");
defaults.Add("action", "index");
defaults.Add("data", string.Empty);
constraints.Add("data", @"[a-zA-Z0-9\-]*");
tokens.Add("namespaces", new[] { Namespace });
tokens.Add("pageId", 0);
routes.Add(new Route("", defaults, constraints, tokens, new MyRouteHandler()));
public class MyRouteHandler : IRouteHandler
{
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
return new MyHttpHandler(requestContext);
}
}
public class MyHttpHandler : MvcHandler
{
public MyHttpHandler(RequestContext requestContext) : base(requestContext)
{
}
protected override void ProcessRequest(HttpContextBase httpContext)
{
int i = 1;
int j = i + 1;
//IController controller = new Web.Controllers.HomeController();
//(controller as Controller).ActionInvoker = new MyActionInvoker();
//controller.Execute(RequestContext);
}