Ejemplo n.º 1
0
        internal static ControllerAction GetViewComponent(string name)
        {
            ControllerClass controllerClass = WebAppConfig.GetViewComponentClass(name);

            if (controllerClass == null)
            {
                return(null);
            }

            return(new ControllerAction(controllerClass));
        }
Ejemplo n.º 2
0
        public static void CreateContext(OfflineWebSession webSession, string method, string url, NameValueCollection postData)
        {
            WebAppConfig.Init(webSession.MapPath);

            HttpContextBase context = new OfflineHttpContext(webSession, method, url, postData);

            Current = context;

            context.SessionObject = WebAppHelper.CreateSessionObject();

            WebAppConfig.Fire_SessionCreated(context.SessionObject);
        }
Ejemplo n.º 3
0
        public ControllerClass CreateControllerClass()
        {
            if (_controllerType != null)
            {
                return(WebAppConfig.GetControllerClass(_controllerType));
            }

            if (_controller != null)
            {
                return(WebAppConfig.GetControllerClass(_controller));
            }

            return(null);
        }
Ejemplo n.º 4
0
//        public RenderViewActionResult(string viewName)
//        {
//            View = new View();
//        }
//
        protected internal override void Execute(HttpContextBase httpContext)
        {
            try
            {
                httpContext.Response.RenderedView = View;
                httpContext.Response.AppendHeader("X-Powered-By", "Vici MVC v" + WebAppConfig.Version);
                httpContext.Response.Write(View.Render());
            }
            catch (TemplateNotFoundException templateException)
            {
                if (!WebAppConfig.Fire_TemplateNotFound(httpContext.Request.RawUrl))
                {
                    httpContext.Response.Write(templateException.Message);
                }
            }
        }
Ejemplo n.º 5
0
        public static void CreateContext(HttpContext httpContext)
        {
            WebAppConfig.Init();

            HttpContextBase context = new OnlineHttpContext(httpContext);

            Current = context;

            if (httpContext.Session == null)
            {
                return;
            }

            context.SessionObject = WebAppHelper.CreateSessionObject();

            WebAppConfig.Fire_SessionCreated(context.SessionObject);
        }
Ejemplo n.º 6
0
        private static void PostMapRequestHandler(object sender, EventArgs e)
        {
            WebAppConfig.Init();

            HttpContext httpContext = ((HttpApplication)sender).Context;

            RequestData requestData = (httpContext.Items[_contextItemKey] as RequestData);

            if (requestData != null)
            {
                httpContext.RewritePath(requestData.Url);

                if (requestData.Handler != null)
                {
                    httpContext.Handler = requestData.Handler;
                }
            }
        }
Ejemplo n.º 7
0
        private static void PostResolveRequestCache(object sender, EventArgs e)
        {
            WebAppConfig.Init();

            HttpContext httpContext = ((HttpApplication)sender).Context;
            HttpRequest httpRequest = httpContext.Request;

            IHttpHandler httpHandler = null;

            string path = UrlHelper.GetUrlPath(httpRequest.AppRelativeCurrentExecutionFilePath, httpRequest.PathInfo);

            if (path.StartsWith("_$ajax$_.axd/"))
            {
                httpHandler = new AjaxPageHandler(path);
            }
            else if (path.StartsWith("_$res$_.axd"))
            {
                httpHandler = new ResourceHttpHandler(path);
            }
            else
            {
                ControllerAction controllerAction = WebAppHelper.GetControllerAction(path);

                if (controllerAction != null)
                {
                    httpHandler = new PageHandler(new MvcPageHandler(controllerAction));
                }
            }

            if (httpHandler != null)
            {
                httpContext.Items[_contextItemKey] = new RequestData(httpContext.Request.RawUrl, httpHandler);

                httpContext.RewritePath("~/ProMesh.axd");
            }
        }
Ejemplo n.º 8
0
        public void ProcessRequest(HttpContextBase httpContext)
        {
            httpContext.Handler = this;

            string baseUrl = UrlHelper.GetUrlPath(httpContext.Request.AppRelativeCurrentExecutionFilePath, httpContext.Request.PathInfo);

            Stopwatch stopWatchRun    = new Stopwatch();
            Stopwatch stopWatchRender = new Stopwatch();
            Stopwatch stopWatchTotal  = new Stopwatch();

            ActionResult actionResult = null;

            try
            {
                try
                {
                    stopWatchTotal.Start();

                    try
                    {
                        stopWatchRun.Start();

                        actionResult = WebAppHelper.RunControllerAction(_controllerAction);
                    }
                    finally
                    {
                        stopWatchRun.Stop();
                    }

                    if (actionResult != null)
                    {
                        try
                        {
                            stopWatchRender.Start();

                            actionResult.Execute(httpContext);
                        }
                        finally
                        {
                            stopWatchRender.Stop();
                        }
                    }
                }
                finally
                {
                    stopWatchTotal.Stop();

                    if (WebAppConfig.LoggingProvider != null)
                    {
                        View view = (actionResult is RenderViewActionResult) ? ((RenderViewActionResult)actionResult).View : null;

                        WebAppConfig.LoggingProvider.LogPage(WebAppContext.Session.SessionID,
                                                             baseUrl,
                                                             GetQueryString(),
                                                             WebAppContext.Session.LanguageCode,
                                                             view != null ? view.LayoutName : null,
                                                             view != null ? view.ViewName : null,
                                                             (int)stopWatchRun.ElapsedMilliseconds,
                                                             (int)stopWatchRender.ElapsedMilliseconds,
                                                             (int)stopWatchTotal.ElapsedMilliseconds);
                    }
                }
            }

            catch (EndResponseException)
            {
                // occurs when Response.End() is called from an offline session (unit test)
            }

            catch (ThreadAbortException)
            {
                throw; // Occurs when Response.End() is called. Rethrow it, because it is handled by the ASP.NET runtime
            }

            catch (Exception ex)
            {
                if (ex.InnerException is ThreadAbortException)
                {
                    throw ex.InnerException;
                }

                WebAppConfig.Fire_ExceptionHandler(ex);
            }
        }