HttpRequest hr = new HttpRequest("", url, "");//这里的url就是要解析的url
TextWriter stringWriter = new StringWriter();
HttpResponse hrs = new HttpResponse(stringWriter);
HttpContext hc = new HttpContext(hr, hrs);
HttpContextWrapper hcw = new HttpContextWrapper(hc); bool blResult = false; foreach (Route r in System.Web.Routing.RouteTable.Routes)
{
RouteData rt = r.GetRouteData(hcw);
if (rt != null)
{
controller = rt.Values["Controller"].ToString();//解析出来的Controller
action = rt.Values["Action"].ToString();//解析出来的Action
blResult = true;
break;
}
}
controller = factory.CreateController(RequestContext, controllerName);