/// <summary> /// 启动MVC服务 /// </summary> /// <param name="controllerNameSpace">分离式的controller</param> /// <param name="port"></param> public void Start(string controllerNameSpace, int port = 39654) { try { if (string.IsNullOrEmpty(controllerNameSpace)) { AreaCollection.RegistAll(); } else { AreaCollection.RegistAll(controllerNameSpace); } } catch (Exception ex) { throw new Exception("当前代码无任何Controller或者不符合MVC 命名规范! err:" + ex.Message); } try { httpServer.Start(port); } catch (Exception ex) { throw new Exception("当前端口已被其他程序占用,请更换端口再做尝试! err:" + ex.Message); } }
/// <summary> /// 启动MVC服务 /// </summary> public void Start(int port = 39654) { try { AreaCollection.RegistAll(); } catch (Exception ex) { throw new Exception("当前代码无任何Controller或者不符合MVC 命名规范! err:" + ex.Message); } try { httpServer.Start(port); } catch (Exception ex) { throw new Exception("当前端口已被其他程序占用,请更换端口再做尝试! err:" + ex.Message); } }
/// <summary> /// 构建mvc容器 /// </summary> /// <param name="root">根目录</param> /// <param name="port">监听端口</param> /// <param name="isStaticsCached">是否启用静态缓存</param> /// <param name="isZiped">是压启用内容压缩</param> /// <param name="bufferSize">http处理数据缓存大小</param> /// <param name="count">http连接数上限</param> /// <param name="controllerNameSpace">注册指定的Controlls空间名</param> /// <param name="isDebug">调试模式</param> public SAEAMvcApplication(string root = "wwwroot", int port = 28080, bool isStaticsCached = true, bool isZiped = false, int bufferSize = 1024 * 10, int count = 10000, string controllerNameSpace = "", bool isDebug = false) { try { if (string.IsNullOrEmpty(controllerNameSpace)) { AreaCollection.RegistAll(); } else { AreaCollection.RegistAll(controllerNameSpace); } } catch (Exception ex) { throw new Exception("当前代码无任何Controller或者不符合MVC 命名规范! err:" + ex.Message); } _webHost = new WebHost(typeof(HttpContext), root, port, isStaticsCached, isZiped, bufferSize, count, 120 * 1000, isDebug); _webHost.RouteParam = AreaCollection.RouteTable; }