Exemplo n.º 1
0
        /// <summary>
        /// Gets a virtual file from the virtual file system.
        /// </summary>
        /// <param name="virtualPath">The path to the virtual file.</param>
        /// <returns>
        /// A descendent of the <see cref="T:System.Web.Hosting.VirtualFile" /> class that represents a file in the virtual file system.
        /// </returns>
        public override VirtualFile GetFile(string virtualPath)
        {
            VirtualFile embeddedResourcesVirtualFile = embeddedResourcesProvider.GetEmbeddedResourceVirtualFile(virtualPath);

            if (embeddedResourcesVirtualFile != null)
            {
                return(embeddedResourcesVirtualFile);
            }

            return(base.GetFile(virtualPath));
        }
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));
        }