public ExecuteRequestCoroutine SetupInternalRequestCoroutine(IHttpContext context, object model, object viewBag) { var executeRequestCoroutine = new ExecuteRequestCoroutine( _virtualDir, context, model, new ModelStateDictionary(), _pathProviders, _renderers, _defaulList, viewBag); executeRequestCoroutine.Initialize(); return executeRequestCoroutine; }
/* internal bool HttpListenerExceptionHandler(Exception ex, IHttpContext context) { var httpException = FindHttpException(ex); if (httpException != null) { WriteException(context, (HttpException)httpException); } else { WriteException(context, 500, ex); } return true; }*/ /* private IRenderer FindRenderer(ref string relativePath, IPathProvider pathProvider, bool isDir) { if (isDir) { string tmpPath = null; for (int i = 0; i < _defaulList.Count; i++) { var def = _defaulList[i]; tmpPath = relativePath.TrimEnd('/') + '/' + def; if (pathProvider.Exists(tmpPath, out isDir)) { if (!isDir) break; } tmpPath = null; } if (tmpPath != null) { relativePath = tmpPath; } } var renderer = GetPossibleRenderer(relativePath); return renderer; }*/ /// <summary> /// Main entry point for the http request. This will be called only upon REAL REQUESTS. Not by /// forwarded items. /// </summary> /// <param name="context"></param> /// <param name="specialHandler"></param> internal void ExecuteRequest(IHttpContext context) { var runner = ServiceLocator.Locator.Resolve<ICoroutinesManager>(); if (context.Request.Url == null) { throw new HttpException(500, string.Format("Missing url.")); } var requestPath = context.Request.Url.LocalPath.Trim(); var relativePath = requestPath; if (requestPath.StartsWith(_virtualDir.TrimEnd('/'))) { relativePath = requestPath.Substring(_virtualDir.Length - 1); } _filtersHandler.OnPreExecute(context); if (_routingHandler != null) { var match = _routingHandler.Resolve(relativePath, context); if (match != null /*&& match.StaticRoute && !match.BlockRoute*/) { if (match.BlockRoute) { ExecuteRequestCoroutine.WriteException(context, new HttpException(404, "Missing " + context.Request.Url)); return; } if (!match.StaticRoute) { var controller = CreateController(match); if (controller != null) { context.RouteParams = match.Parameters ?? new Dictionary<string, object>(); controller.Instance.Set("Httpcontext", context); runner.StartCoroutine( new RoutedItemCoroutine(match, controller, context, _conversionService, null)); return; } } } } var executeRequestCoroutine = new ExecuteRequestCoroutine( _virtualDir, context, null, new ModelStateDictionary(), _pathProviders, _renderers, _defaulList,new ExpandoObject()); executeRequestCoroutine.Initialize(); runner.StartCoroutine(executeRequestCoroutine); }