Example #1
0
            public void ProcessRequest(HttpContext context)
            {
                var version = ClientScriptReference.GetContentHash(context.Request.Url.AbsolutePath);

                if (string.Equals(context.Request.Headers["If-None-Match"], version))
                {
                    context.Response.StatusCode = (int)HttpStatusCode.NotModified;
                }
                else
                {
                    context.Response.Write(CopyrigthTransform.CopyrigthText);
                    context.Response.Write(ClientScriptReference.GetContent(context.Request.Url.AbsolutePath));
                    context.Response.Charset     = Encoding.UTF8.WebName;
                    context.Response.ContentType = new ContentType("application/x-javascript")
                    {
                        CharSet = Encoding.UTF8.WebName
                    }.ToString();

                    // cache
                    context.Response.Cache.SetVaryByCustom("*");
                    context.Response.Cache.SetAllowResponseInBrowserHistory(true);
                    context.Response.Cache.SetETag(version);
                    context.Response.Cache.SetCacheability(HttpCacheability.Public);
                    context.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
                }
            }
Example #2
0
            public override Stream Open()
            {
                var stream = new MemoryStream();
                var buffer = Encoding.UTF8.GetBytes(ClientScriptReference.GetContent(VirtualPath));

                stream.Write(buffer, 0, buffer.Length);
                stream.Seek(0, SeekOrigin.Begin);
                return(stream);
            }
Example #3
0
            public override async Task ProcessRequestAsync(HttpContext context)
            {
                try
                {
                    HttpContext.Current = context;
                    var clientScriptReference = new ClientScriptReference();
                    var version = clientScriptReference.GetContentHash(context.Request.Url.AbsolutePath);
                    if (string.Equals(context.Request.Headers["If-None-Match"], version))
                    {
                        context.Response.StatusCode = (int)HttpStatusCode.NotModified;
                    }
                    else
                    {
                        context.Response.Charset     = Encoding.UTF8.WebName;
                        context.Response.ContentType = new ContentType("application/x-javascript")
                        {
                            CharSet = Encoding.UTF8.WebName
                        }.ToString();

                        // cache
                        context.Response.Cache.SetVaryByCustom("*");
                        context.Response.Cache.SetAllowResponseInBrowserHistory(true);
                        context.Response.Cache.SetETag(version);
                        context.Response.Cache.SetCacheability(HttpCacheability.Public);

                        // body
                        var content = Encoding.UTF8.GetBytes(await clientScriptReference.GetContentAsync(context));

                        using (var inputStream = new MemoryStream())
                        {
                            if (ClientSettings.GZipEnabled)
                            {
                                using (var zip = new GZipStream(inputStream, CompressionMode.Compress, true))
                                {
                                    await zip.WriteAsync(content, 0, content.Length);

                                    zip.Flush();
                                }
                                context.Response.Headers["Content-Encoding"] = "gzip";
                            }
                            else
                            {
                                await inputStream.WriteAsync(content, 0, content.Length);
                            }
                            inputStream.Position = 0;
                            inputStream.CopyTo(context.Response.OutputStream);
                        }
                    }
                }
                catch (Exception e)
                {
                    LogManager.GetLogger("ASC").Error("ClientScriptHandler", e);
                }
            }
        public void AddClientLocalizationScript(Type type)
        {
            if (clientScriptReference == null)
                clientScriptReference = new ClientScriptReference();

            clientScriptReference.Includes.Add(type);
        }
        private void InitScripts()
        {
            AddStyles("~/skins/<theme_folder>/main.less", true);

            AddClientScript(typeof(MasterResources.MasterSettingsResources));
            AddClientScript(typeof(MasterResources.MasterUserResources));
            AddClientScript(typeof(MasterResources.MasterFileUtilityResources));
            AddClientScript(typeof(MasterResources.MasterCustomResources));

            InitProductSettingsInlineScript();
            InitStudioSettingsInlineScript();

            if (ClientLocalizationScript != null)
            {
                AddClientLocalizationScript(typeof(MasterResources.MasterLocalizationResources));
                AddClientLocalizationScript(typeof(MasterResources.MasterTemplateResources));

                if (clientScriptReference == null)
                {
                    clientScriptReference = new ClientScriptReference();
                }
                if (0 < clientScriptReference.Includes.Count)
                {
                    ClientLocalizationScript.Scripts.Add(clientScriptReference.GetLink(true));
                }
            }
        }
        private void InitScripts()
        {
            AddCommon(LoadControl(VirtualPathUtility.ToAbsolute("~/Masters/CommonStyles.ascx")), HeadStyles);
            AddCommon(LoadControl(VirtualPathUtility.ToAbsolute("~/Masters/CommonBodyScripts.ascx")), BodyScripts);
            AddStyles("~/skins/<theme_folder>/main.less", true);

            AddClientScript(typeof(MasterResources.MasterSettingsResources));
            AddClientScript(typeof(MasterResources.MasterUserResources));
            AddClientScript(typeof(MasterResources.MasterFileUtilityResources));
            AddClientScript(typeof(MasterResources.MasterCustomResources));

            if (ClientLocalizationScript != null)
            {
                AddClientLocalizationScript(typeof(MasterResources.MasterLocalizationResources));
                AddClientLocalizationScript(typeof(MasterResources.MasterTemplateResources));

                if (clientScriptReference == null)
                {
                    clientScriptReference = new ClientScriptReference();
                }
                if (0 < clientScriptReference.Includes.Count)
                {
                    ClientLocalizationScript.Scripts.Add(clientScriptReference.GetLink(true));
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (SecurityContext.IsAuthenticated && User.ID != SecurityContext.CurrentAccount.ID)
            {
                Response.Redirect(GetRefererURL());
                return;
            }

            _communitations.Controls.Add(LoadControl(AuthCommunications.Location));

            AjaxPro.Utility.RegisterTypeForAjax(GetType());

            Page.RegisterBodyScripts(ResolveUrl("~/usercontrols/Management/SmsControls/js/confirmmobile.js"));
            Page.RegisterStyleControl(VirtualPathUtility.ToAbsolute("~/usercontrols/management/SmsControls/css/confirmmobile.less"));

            Context.Session["SmsAuthData"] = User.ID;

            if (string.IsNullOrEmpty(User.MobilePhone))
                Activation = true;

            if (!Activation)
            {
                try
                {
                    SmsManager.PutAuthCode(User, false);
                }
                catch (Exception)
                {
                    Activation = true;
                }
            }

            if (Activation)
            {
                var ipGeolocationInfo = new GeolocationHelper("teamlabsite").GetIPGeolocationFromHttpContext();
                if (ipGeolocationInfo != null) Country = ipGeolocationInfo.Key;

                var clientScriptReference = new ClientScriptReference();
                clientScriptReference.Includes.Add(typeof(CountriesResources));
                Page.RegisterBodyScripts(clientScriptReference);

                Page.RegisterBodyScripts(ResolveUrl("~/js/asc/plugins/countries.js"));
                Page.RegisterBodyScripts(ResolveUrl("~/js/asc/plugins/phonecontroller.js"));
                Page.RegisterStyleControl(VirtualPathUtility.ToAbsolute("~/skins/default/phonecontroller.css"));
            }
        }