private void InvokeClass() { Type t = null; //ViewController是由页面的前两个路径决定了。 string[] items = QueryTool.GetLocalPath().Trim('/').Split('/'); string className = InvokeLogic.Default; if (RouteConfig.RouteMode == 1) { className = items[0]; } else if (RouteConfig.RouteMode == 2) { className = items.Length > 1 ? items[1] : ""; } t = InvokeLogic.GetType(className); if (t == null) { WriteError("You need a controller for coding!"); } try { object o = Activator.CreateInstance(t);//实例化 t.GetMethod("ProcessRequest").Invoke(o, new object[] { context }); } catch (ThreadAbortException e) { //ASP.NET 的机制就是通过异常退出线程(不要觉的奇怪) } catch (Exception err) { WriteError(err.Message); } }
private void InvokeClass() { string localPath = context.Request.Url.LocalPath; Type t = null; if (localPath.IndexOf(".") == -1) // 处理Mvc请求 { //ViewController是由页面的前两个路径决定了。 string[] items = localPath.Trim('/').Split('/'); string className = items[0]; if (RouteConfig.RouteMode == 2) { className = items.Length > 1 ? items[1] : ""; } t = InvokeLogic.GetType(className); if (t == null) { WriteError("Can't find the controller!"); } try { object o = Activator.CreateInstance(t);//实例化 t.GetMethod("ProcessRequest").Invoke(o, new object[] { context }); } catch (ThreadAbortException e) { //ASP.NET 的机制就是通过异常退出线程(不要觉的奇怪) } catch (Exception err) { WriteError(err.Message); } } }