Exemplo n.º 1
0
        /// <summary>
        /// Creates a cache dependency based on the specified virtual paths.
        /// </summary>
        /// <param name="virtualPath">The path to the primary virtual resource.</param>
        /// <param name="virtualPathDependencies">An array of paths to other resources required by the primary virtual resource.</param>
        /// <param name="utcStart">The UTC time at which the virtual resources were read.</param>
        /// <returns>
        /// A <see cref="T:System.Web.Caching.CacheDependency" /> object for the specified virtual resources.
        /// </returns>
        public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
        {
            if (embeddedResourcesProvider.IsEmbeddedResourceVirtualPath(virtualPath))
            {
                return(null);
            }

            string[] strArray = (from s in virtualPathDependencies.OfType <string>()
                                 where !embeddedResourcesProvider.IsEmbeddedResourceVirtualPath(s)
                                 select s).ToArray <string>();

            return(base.GetCacheDependency(virtualPath, strArray, utcStart));
        }
Exemplo n.º 2
0
        public ActionResult Index(string area = null, string folder1 = null, string folder2 = null, string folder3 = null, string folder4 = null, string folder5 = null, string folder6 = null, string file = null, string resourceType = null)
        {
            string contentType = GetContentType(resourceType);

            if (string.IsNullOrEmpty(contentType))
            {
                Response.StatusCode = 404;
                return(new EmptyResult());
            }

            string[] folders = new[]
            {
                folder1,
                folder2,
                folder3,
                folder4,
                folder5,
                folder6
            };

            string virtualPath = "~/Areas/" + area + "/";

            for (int i = 0; i < folders.Length; i++)
            {
                if (!string.IsNullOrEmpty(folders[i]))
                {
                    virtualPath += folders[i] + "/";
                }
            }

            virtualPath += file + "." + resourceType;

            if (!embeddedResourcesProvider.IsEmbeddedResourceVirtualPath(virtualPath))
            {
                Response.StatusCode = 404;
                return(new EmptyResult());
            }

            var virtualFile = embeddedResourcesProvider.GetEmbeddedResourceVirtualFile(virtualPath);

            return(File(virtualFile.Open(), contentType));
        }