Ext.Net.ResourceHandler.HasHandler C# (CSharp) Method

HasHandler() private method

private HasHandler ( ) : bool
return bool
        public static bool HasHandler()
        {
            if (HttpContext.Current.Application["HasHandler"] != null)
            {
                return (bool)HttpContext.Current.Application["HasHandler"];
            }

            bool result = false;
            string path = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "web.config");
            XmlTextReader reader = new XmlTextReader(new StreamReader(path));

            try
            {
                if (reader.ReadToFollowing("httpHandlers"))
                {
                    if (reader.ReadInnerXml().Contains("type=\"Ext.Net.ResourceHandler\""))
                    {
                        result = true;
                    }
                }
            }
            catch
            {
                result = false;
            }
            finally
            {
                reader.Close();
            }

            HttpContext.Current.Application["HasHandler"] = result;

            return result;
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="resourceName"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public static string GetWebResourceUrl(Type type, string resourceName)
        {
            if (resourceName.StartsWith(ResourceManager.ASSEMBLYSLUG) && ExtNetTransformer.CleanResourceUrl && ResourceHandler.HasHandler())
            {
                string buster = (resourceName.EndsWith(".js") || resourceName.EndsWith(".css")) ? "?v=".ConcatWith(ResourceManager.CacheBuster) : "";

                string url = "~{0}/ext.axd{1}".FormatWith(resourceName.Replace(ResourceManager.ASSEMBLYSLUG, "").Replace('.', '/').ReplaceLastInstanceOf("/", "-"), buster);

                return(ExtNetTransformer.ResolveUrl(url));
            }

            return(HttpUtility.HtmlAttributeEncode(CachedPageInstance.ClientScript.GetWebResourceUrl(type, resourceName)));
        }
All Usage Examples Of Ext.Net.ResourceHandler::HasHandler