Exemplo n.º 1
0
 public static new Settings GetSettings()
 {
     return(BasePage.GetSettings());
 }
Exemplo n.º 2
0
        private void Application_BeginRequest(Object source, EventArgs e)
        {
            var installerPath    = "~/Installer/";
            var absInstallerUrl  = URIHelper.ConvertToAbsUrl(installerPath);
            var absInstallerPath = URIHelper.ConvertToAbsPath(installerPath);

            if (Request.CurrentExecutionFilePathExtension == "" && !Request.Url.AbsoluteUri.StartsWith(absInstallerUrl))
            {
                if (Directory.Exists(absInstallerPath) && AppSettings.EnableInstaller)
                {
                    Response.Redirect(installerPath);
                }
            }


            if (AppSettings.ForceWWWRedirect)
            {
                var isSubDomain = (Request.Url.AbsoluteUri.Split('.').Length > 2);

                if (!AppSettings.IsRunningOnProd && (!Request.Url.Host.StartsWith("www.") && !Request.Url.Host.StartsWith("localhost") && !isSubDomain))
                {
                    Response.RedirectPermanent(Request.Url.AbsoluteUri.Replace("://", "://www."));
                }
            }
            else
            {
                if (Request.Url.Host.StartsWith("www."))
                {
                    Response.RedirectPermanent(Request.Url.AbsoluteUri.Replace("www.", ""));
                }
            }


            BaseService.AddResponseHeaders();

            var virtualPathRequest = HttpContext.Current.Request.Path.EndsWith("/");

            if (virtualPathRequest)
            {
                Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
                Response.Cache.SetNoStore();
            }

            if (isFirstApplicationRequest)
            {
                ContextHelper.ClearAllMemoryCache();
                FrameworkBaseMedia.InitConnectionSettings(AppSettings.GetConnectionSettings());
                isFirstApplicationRequest = false;
            }

            if (Request.Url.AbsolutePath.Contains("robots.txt"))
            {
                var absPath = URIHelper.ConvertToAbsPath(Request.Url.AbsolutePath);

                if (File.Exists(absPath))
                {
                    var fileContent = File.ReadAllText(absPath);

                    var parsedContent = ParserHelper.ParseData(fileContent, BasePage.GetDefaultTemplateVars(""));

                    BaseService.WriteText(parsedContent);
                }
            }
        }