Exemplo n.º 1
0
        private void application_BeginRequest(object sender, EventArgs e)
        {
            HttpContext context           = ((HttpApplication)sender).Context;
            HttpRequest request           = context.Request;
            string      filePath          = request.FilePath;
            string      executionFilePath = request.AppRelativeCurrentExecutionFilePath;

            GlobalCulture.SetContextCulture();
            LogicContext current = LogicContext.Current;

            current.SetDatabase(AppConfig.DefaultDbId);
            current.Source = filePath;
            HttpCookie cookie = request.Cookies[CookieMemory.FormsCookieName];
            bool       flag   = cookie != null;

            if (flag)
            {
                CookieMemory cookie2      = new CookieMemory(cookie);
                LogicSession logicSession = AuthUtils.GetLogicSession(cookie2);
                bool         flag2        = logicSession != null && logicSession.UserId == cookie2.UserId;
                if (!flag2)
                {
                    AppEventLog.Debug("无法恢复");
                    return;
                }
                current.CookieUpdateTime     = cookie2.UpdateTime;
                logicSession.LastRequestTime = AppRuntime.ServerDateTime;
                current.SetLogicSession(logicSession);
                current.UserAuthCookies = cookie;
            }
            bool flag3 = filePath == null;

            if (!flag3)
            {
                string s     = StringHelper.RightSubstring(filePath, 5);
                bool   flag4 = (!StringHelper.EqualsIgnoreCase(s, ".aspx") && !StringHelper.EqualsIgnoreCase(s, ".asmx") && !StringHelper.EqualsIgnoreCase(s, ".ashx")) || context.Request.Url.ToString().IndexOf("ActiveModule.aspx") < 0;
                if (!flag4)
                {
                    string routeUrl = ModuleUtils.GetRouteUrl(request.QueryString["AMID"].ToString().Trim().ToInt());
                    current.AmId = request.QueryString["AMID"].ToString().Trim().ToInt();
                    bool flag5 = routeUrl.IndexOf("?") < 0;
                    if (flag5)
                    {
                        context.Response.Redirect(routeUrl + "?" + context.Request.QueryString, false);
                    }
                    else
                    {
                        context.Response.Redirect(routeUrl + "&" + context.Request.QueryString, false);
                    }
                }
            }
        }