문제

때때로 J2EE에 정통한 사람들은 asp.net을보고 궁금해합니다. 앱을 단일 장치로 배포하는 지원은 어디에 있습니까?? JSP/Servlet 앱은 해당 단일 아카이브의 모든 페이지, 컨텐츠, 메타 데이터 및 코드와 함께 전쟁 파일로 배포 할 수 있습니다. 전쟁 파일은 버전으로 만들 수 있으며 쉽게 움직일 수 있습니다. 전체 앱이 단일 장치에 포함되어 있다는 확신이 있습니다.

ASP.NET의 주류 접근 방식이 아닙니다. 사람들은 무엇을합니까? 그들은 디렉토리와 모든 무수한 파일을 복사하는 데 의지합니까? ASP.NET 개발자에게는 이것이 문제가되지 않습니까?

(이것은 내 자신의 대답을 제안 할 것이기 때문에 일종의 속임수입니다)

도움이 되었습니까?

해결책

ASP.NET의 주류 접근 방식은 아니지만 이는 VirtualPathProvider asp.net의 경우. 그것으로, 당신은 파일 시스템이 아닌 것들로부터 웹 사이트 콘텐츠를 제공 할 수 있습니다. 예를 들어, 파일을 디스크로 삭제하지 않고 ZIP 파일에서 직접 ASP.NET 웹 사이트를 제공 할 수 있습니다.

여기 다운로드가 있습니다 DotnetZip 라이브러리를 사용하여 ASP.NET이 ZIP에서 컨텐츠를 끌어내는 데 도움이되는 개념을 보여 주거나 설명합니다.

흥미로운 코드 비트 :

using Ionic.Zip;

namespace Ionic.Zip.Web.VirtualPathProvider
{
    public class ZipFileVirtualPathProvider : System.Web.Hosting.VirtualPathProvider
    {
        ZipFile _zipFile;

        public ZipFileVirtualPathProvider (string zipFilename)
            : base () {
            _zipFile =  ZipFile.Read(zipFilename);
        }

        ~ZipFileVirtualPathProvider () {
            _zipFile.Dispose ();
        }

        public override bool FileExists (string virtualPath)
        {
            string zipPath = Util.ConvertVirtualPathToZipPath (virtualPath, true);
            ZipEntry zipEntry = _zipFile[zipPath];

            if (zipEntry != null)
            {
                return !zipEntry.IsDirectory;
            }
            else
            {
                // Here you may want to return Previous.FileExists(virtualPath) instead of false
                // if you want to give the previously registered provider a process to serve the file
                return false;
            }
        }

        public override bool DirectoryExists (string virtualDir)
        {
            string zipPath = Util.ConvertVirtualPathToZipPath (virtualDir, false);
            ZipEntry zipEntry = _zipFile[zipPath];

            if (zipEntry != null)
            {
                return zipEntry.IsDirectory;
            }
            else
            {
                // Here you may want to return Previous.DirectoryExists(virtualDir) instead of false
                // if you want to give the previously registered provider a chance to process the directory
                return false;
            }
        }

        public override VirtualFile GetFile (string virtualPath) {
            return new ZipVirtualFile (virtualPath, _zipFile);
        }

        public override VirtualDirectory GetDirectory (string virtualDir)
        {
            return new ZipVirtualDirectory (virtualDir, _zipFile);
        }

        public override string GetFileHash(string virtualPath, System.Collections.IEnumerable virtualPathDependencies)
        {
            return null;
        }

        public override System.Web.Caching.CacheDependency GetCacheDependency(String virtualPath, System.Collections.IEnumerable virtualPathDependencies, DateTime utcStart)
        {
            return null;
        }
    }
}

VPP Construct는 ASP.NET 2.0 이상에서 작동하며 모든 웹 사이트에서 작동합니다. 물론 데이터베이스, CMS에서 컨텐츠를 소스하기 위해 아이디어를 조정할 수 있습니다.

다른 팁

솔루션의 일부는입니다 임베디드 리소스. 그것은 모든 정적 파일을 처리합니다.

솔루션의 일부는 a를 사용하는 것입니다 웹 배포 프로젝트, 모든 페이지 (예 : 업데이트 할 수 없음)를 단일 어셈블리로 컴파일합니다. 모든 .CS 파일을 처리합니다.

따라서 남은 것은 .dll 파일과 .aspx 스터브 파일을 지원하는 bin의 .dll입니다. IIS는 기본적으로 ASPX 파일이 서버를 시도하기 전에 존재하기를 원합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top