Ejemplo n.º 1
0
        private string RunPage(string url, bool post)
        {
            for (; ;)
            {
                _redirectedPage = null;
                _currentPage    = url;

                try
                {
                    HttpContextBase.CreateContext(this, post ? "POST" : "GET", url, post ? _postData : null);

                    if (ContextCreated != null)
                    {
                        ContextCreated(this, new ContextCreatedEventArgs(this, WebAppContext.HttpContext));
                    }

                    IHttpRequest httpRequest = WebAppContext.Request;

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

                    ControllerAction controllerAction = WebAppHelper.GetControllerAction(path);

                    MvcPageHandler pageHandler = new MvcPageHandler(controllerAction);

                    pageHandler.ProcessRequest(WebAppContext.HttpContext);

                    _isNewSession = false;

                    _view = WebAppContext.HttpContext.Response.RenderedView;
                }
                catch (TargetInvocationException ex)
                {
                    Exception ex2 = ExceptionHelper.ResolveTargetInvocationException(ex);

                    if (!(ex2 is EndResponseException))
                    {
                        throw ex2;
                    }
                }
                catch (EndResponseException)
                {
                }

                _redirectedPage = ((OfflineHttpResponse)WebAppContext.HttpContext.Response).RedirectedUrl;

                PostData.Clear();

                if (!_followRedirects || _redirectedPage == null)
                {
                    return(WebAppContext.Response.Output);
                }

                post = false;
                url  = _redirectedPage;
            }
        }
Ejemplo n.º 2
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");
            }
        }