public void ProcessRequest(HttpContext context) { RouteData routeData = context.Request.RequestContext.RouteData; var cfg = MiniMvcSystem.Config; var mvc = MiniMvcSystem.GetInstance(); // Find the controller var ctrlName = (string)routeData.Values["controller"] ?? cfg.DefaultController; if (!mvc.Controllers.ContainsKey(ctrlName)) { throw new ControllerNotFoundException(ctrlName); } var ctrl = Activator.CreateInstance(mvc.Controllers[ctrlName]) as Controller; // Find the action ctrl.LoadActions(); var action = (string)routeData.Values["action"] ?? cfg.DefaultAction; if (!ctrl.Actions.ContainsKey(action)) { throw new ActionNotFoundException(ctrlName, action); } ctrl.RunAction(action); }
public RouteCollection GetRoutes() { var rc = new RouteCollection(); var cfg = MiniMvcSystem.Config; foreach (RouteElement route in cfg.Routes) { var rd = new RouteValueDictionary { { "controller", route.Controller }, { "action", route.Action } }; rc.Add(route.Name, new Route(route.Url, rd, MiniMvcSystem.GetRouteHandler())); } return(rc); }