void OnPostAcquireRequestState(object source, EventArgs e)
    {
        HttpApplication app = (HttpApplication)source;

        MyHttpHandler resourceHttpHandler = HttpContext.Current.Handler as MyHttpHandler;

        if (resourceHttpHandler != null)
        {
            HttpContext.Current.Handler = resourceHttpHandler.OriginalHandler;
        }
    }
    void Application_PostAcquireRequestState(object source, EventArgs e)
    {
        HttpApplication app = (HttpApplication)source;

        MyHttpHandler resourceHttpHandler = HttpContext.Current.Handler as MyHttpHandler;

        if (resourceHttpHandler != null)
        {
            // set the original handler back
            HttpContext.Current.Handler = resourceHttpHandler.OriginalHandler;
        }

        // -> at this point session state should be available

        Debug.Assert(app.Session != null, "it did not work :(");
    }
Ejemplo n.º 3
0
        private void Application_PostAcquireRequestState(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;

            if (app.Context.Request.RawUrl.ToLower().Contains(Configuration.Tenor.Current.TenorModule.HandlerFileName.ToLower()))
            {
                MyHttpHandler resourceHttpHandler = HttpContext.Current.Handler as MyHttpHandler;



                if (resourceHttpHandler != null)
                {
                    HttpContext.Current.Handler = resourceHttpHandler.originalHandler;
                }
                /*System.Diagnostics.Debug.Assert(app.Session == null, "oops, it did not work :(");*/
            }
        }
Ejemplo n.º 4
0
//-------------------------------------------------------------------------------------------
        void Application_PostAcquireRequestState(object source, EventArgs e)
        {
            HttpApplication app = (HttpApplication)source;

            MyHttpHandler resourceHttpHandler = HttpContext.Current.Handler as MyHttpHandler;

            if (resourceHttpHandler != null)
            {
                // set the original handler back
                HttpContext.Current.Handler = resourceHttpHandler.OriginalHandler;
            }

            // -> at this point session state should be available

            string url     = app.Context.Request.Url.ToString(); // url: http://www.weavver.local/default.aspx
            string path    = app.Context.Request.Path;           // path: /default.aspx OR /org/default/company/services/hosting/
            string exten   = System.IO.Path.GetExtension(app.Context.Request.Path);
            string newpath = path;
            string org     = "default";

            // protects autocomplete
            if (url.Contains(".asmx/"))
            {
                return;
            }

            string query = "";

            if (HttpContext.Current.Request.QueryString.HasKeys())
            {
                query += HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString.ToString());
            }

            // checks for dynamic urls (pages/content that only lives in the database)
            if (app.Context.Session != null && app.Context.Session["SelectedOrganizationId"] != null)
            {
                Guid selectedOrganizationId = (Guid)app.Context.Session["SelectedOrganizationId"];
                if (ConfigurationManager.AppSettings["install_mode"] == "false")
                {
                    using (WeavverEntityContainer data = new WeavverEntityContainer())
                    {
                        var dynamicUrl = (from x in data.System_URLs
                                          where x.Path == path &&
                                          x.OrganizationId == selectedOrganizationId
                                          select x).FirstOrDefault();

                        if (dynamicUrl != null)
                        {
                            query = "Id=" + dynamicUrl.ObjectId.ToString();
                            HttpContext.Current.RewritePath("/" + dynamicUrl.TableName + "/" + dynamicUrl.PageTemplate + ".aspx", null, query, false);
                            return;
                        }
                    }
                }
            }

            if (exten == "" && !newpath.ToLower().Contains(".aspx/"))
            {
                //string filepath = HttpContext.Current.Server.MapPath("~" + path + ".aspx");
                //if (urlparts.Length >= 2)

                if (path.Length > 5 && path.StartsWith("/org/"))
                {
                    newpath = path.Substring(5);
                    if (newpath.Contains("/"))
                    {
                        org     = newpath.Substring(0, newpath.IndexOf("/"));
                        newpath = newpath.Substring(newpath.IndexOf("/"));
                    }
                    if (newpath.Contains("?"))
                    {
                        newpath = newpath.Substring(0, newpath.IndexOf("?") + 1);
                    }
                }

                if (String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["org"]))
                {
                    query = "org=" + org + "&" + query;
                }

                if (newpath.EndsWith("/"))
                {
                    newpath += "Default.aspx";
                }
                else if (!newpath.ToLower().EndsWith(".aspx"))
                {
                    newpath += ".aspx";
                }

                if (ConfigurationManager.AppSettings["debug"] == "yes")
                {
                    string logmsg = "WeavverHttpModule: Url: " + url + " Path: " + path + " New Path: " + newpath + " -- " + HttpContext.Current.Request.PathInfo;
                    Weavver.Utilities.ErrorHandling.SendError(new Exception(logmsg));
                }

                string filePath = HttpContext.Current.Server.MapPath(newpath);
                if (!System.IO.File.Exists(filePath))
                {
                    newpath = "/System/HTTP404.aspx";
                }

                HttpContext.Current.RewritePath(newpath, null, query, false);
            }

            Debug.Assert(app.Session != null, "it did not work :(");
        }