Ejemplo n.º 1
0
        /// <summary>
        /// The Application_BeginRequest function is where all the URL re-writing magic happens.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Application_BeginRequest(Object sender, EventArgs e)
        {
            Console.WriteLine("Application - Application_BeginRequest");

            ProcessSwfUploadFixes(); // this needs to be before the UrlsToNotRemap is checked.

            // get the requested page path
            string baseProcessingPage = CmsContext.ApplicationPath + "default.aspx";
            string pagePath           = Request.Url.AbsolutePath.Substring(CmsContext.ApplicationPath.Length);

            // do not process the urls in "URLsToNotRemap" configuration entry.
            if (StringUtils.IndexOf(CmsConfig.URLsToNotRemap, pagePath, StringComparison.CurrentCultureIgnoreCase) != -1)
            {
                return;
            }


            // only re-map ASPX files
            string extension = System.IO.Path.GetExtension(pagePath);

            if (String.Compare(extension, ".aspx", true) != 0)
            {
                return;
            }

            CmsContext.StartNewRequest();

            // remove extension
            pagePath = pagePath.Substring(0, pagePath.Length - ".aspx".Length);

            if (String.Compare(pagePath, "default", true) == 0)
            {
                pagePath = "/";
            }


            if (!pagePath.StartsWith("/"))
            {
                pagePath = "/" + pagePath;
            }

            string queryString = "p=" + pagePath; // note: no starting "?"

            if (Request.Url.Query != "")
            {
                string query = Request.Url.Query;
                if (query.StartsWith("?"))
                {
                    // replace beginning "?" with "&"
                    query = query.Substring(1);
                    query = "&" + query;
                }
                queryString += query;
            }

            // send the request to the default.aspx page with the page path in the querystring.
            Context.RewritePath(baseProcessingPage, null, queryString);
        }
Ejemplo n.º 2
0
        }         // page_load

        protected override void CreateChildControls()
        {
            try
            {
                string aspxerrorpath = PageUtils.getFromForm("aspxerrorpath", "");
                if (aspxerrorpath.Trim() != "")
                {
                    throw new CmsPageNotFoundException();
                }


                CmsContext.StartNewRequest();
                // fires the CmsPage.CreateChildControls function
                this.Controls.Add(CmsContext.currentPage.ToWebControl());
                // (do not use CmsContext.currentPage.Render)
            }
            catch (CmsPageNotFoundException ex404)
            {
                Console.Write(ex404.Message);
                CmsContext.HandleNotFoundException();
            }
        }         // CreateChildControls