Development Tip

ASP.NET 웹 사이트 또는 ASP.NET 웹 응용 프로그램?

yourdevel 2020. 9. 28. 10:14
반응형

ASP.NET 웹 사이트 또는 ASP.NET 웹 응용 프로그램?


Visual Studio에서 새 ASP.NET 프로젝트를 시작할 때 ASP.NET 웹 응용 프로그램을 만들거나 ASP.NET 웹 사이트를 만들 수 있습니다.

ASP.NET 웹 응용 프로그램과 ASP.NET 웹 사이트의 차이점은 무엇입니까? 왜 다른 것보다 하나를 선택해야합니까?

사용중인 Visual Studio 버전에 따라 대답이 다른가요?


웹 사이트 :

웹 사이트 프로젝트는 즉시 컴파일됩니다. 결국 훨씬 더 많은 DLL 파일이 생성되어 고통 스러울 수 있습니다. 또한 다른 디렉토리가 아직 코드로 컴파일되지 않았을 수 있기 때문에 다른 디렉토리의 페이지와 컨트롤을 참조해야하는 페이지 또는 컨트롤이 한 디렉토리에있을 때 문제가 발생합니다. 게시에 또 다른 문제가있을 수 있습니다.

Visual Studio가 동일한 이름을 지속적으로 재사용하도록 지시하지 않으면 페이지에서 항상 생성되는 DLL 파일의 새 이름이 표시됩니다. 이로 인해 동일한 클래스 이름을 포함하는 DLL 파일의 근접 복사본이 여러 개 생성되어 많은 오류가 발생할 수 있습니다. 웹 사이트 프로젝트는 Visual Studio 2005와 함께 도입되었지만 그다지 인기가없는 것으로 밝혀졌습니다.

웹 애플리케이션 :

웹 응용 프로그램 프로젝트는 추가로 만들어 지금 2005 년의 주요 차이점은 웹 응용 프로그램 프로젝트는 비주얼 스튜디오 2003 그것은 의지와 함께 제공하는 웹 프로젝트와 유사한 작동하도록 설계되었다 있습니다 Visual Studio를위한 SP 1의 한 부분으로 존재했다 빌드시 애플리케이션을 단일 DLL 파일로 컴파일합니다. 프로젝트를 업데이트하려면 다시 컴파일하고 변경 사항이 발생하도록 DLL 파일을 게시해야합니다.

웹 애플리케이션 프로젝트의 또 다른 좋은 기능은 프로젝트보기에서 파일을 제외하는 것이 훨씬 쉽다는 것입니다. 웹 사이트 프로젝트에서 제외하는 각 파일은 파일 이름에 제외 된 키워드로 이름이 바뀝니다. 웹 응용 프로그램 프로젝트에서 프로젝트는 이름을 바꾸지 않고 프로젝트보기에서 포함 / 제외 할 파일을 추적하기 만하면 작업이 훨씬 깔끔해집니다.

참고

기사 ASP.NET 2.0-웹 사이트 대 웹 응용 프로그램 프로젝트 는 하나만 사용해야하는 이유를 설명합니다. 다음은 그 일부입니다.

  • 대규모 Visual Studio .NET 2003 응용 프로그램을 VS 2005로 마이그레이션해야합니까? 웹 애플리케이션 프로젝트를 사용하십시오.
  • 프로젝트 파일을 생성하지 않고 웹 프로젝트로 디렉토리를 열고 편집하고 싶습니까? 웹 사이트 프로젝트를 사용하십시오.
  • 컴파일 중에 사전 빌드 및 사후 빌드 단계를 추가해야합니까? 웹 응용 프로그램 프로젝트를 사용하십시오.
  • 여러 웹 프로젝트를 사용하여 웹 애플리케이션을 구축해야합니까? 웹 응용 프로그램 프로젝트를 사용하십시오.
  • 각 페이지에 대해 하나의 어셈블리를 생성 하시겠습니까? 웹 사이트 프로젝트를 사용하십시오.
  • 각 페이지보기에서 전체 사이트를 구축하지 않고 동적 컴파일 및 페이지 작업을 선호하십니까? 웹 사이트 프로젝트를 사용하십시오.
  • 코드 숨김 모델보다 단일 페이지 코드 모델을 선호하십니까? 웹 사이트 프로젝트를 사용하십시오.

웹 응용 프로그램 프로젝트와 웹 사이트 프로젝트 (MSDN)는 웹 사이트와 웹 응용 프로그램 프로젝트의 차이점을 설명합니다. 또한 Visual Studio에서 구성 할 구성에 대해서도 설명합니다.


웹 사이트 는 IIS와 같은 ASP.NET 웹 서버에 배포하는 것입니다. 파일과 폴더의 무리. 웹 사이트에는 Visual Studio와 연결되는 것이 없습니다 (프로젝트 파일 없음). 웹 페이지의 코드 생성 및 컴파일 (예 : .aspx, .ascx, .master)은 런타임에 동적으로 수행 되며 이러한 파일의 변경 사항은 프레임 워크에 의해 감지되고 자동으로 다시 컴파일됩니다. 페이지간에 공유 할 코드를 특수 App_Code 폴더에 넣거나 미리 컴파일하고 어셈블리를 Bin 폴더에 넣을 수 있습니다.

웹 애플리케이션 은 특별한 Visual Studio 프로젝트입니다. 웹 사이트와의 주요 차이점은 프로젝트를 빌드 할 때 모든 코드 파일이 bin 디렉터리에있는 단일 어셈블리로 컴파일된다는 것입니다. 웹 서버에 코드 파일을 배포하지 않습니다. 공유 코드 파일을위한 특수 폴더를 사용하는 대신 클래스 라이브러리에서하는 것처럼 어디에나 저장할 수 있습니다. 웹 응용 프로그램에는 프로젝트 및 코드 파일과 같이 배포 할 의도가없는 파일이 포함되어 있기 때문에 Visual Studio에는 지정된 위치에 웹 사이트를 출력하는 게시 명령이 있습니다.

App_Code 대 Bin

공유 코드 파일을 배포하는 것은 일반적으로 나쁜 생각이지만 웹 애플리케이션을 선택해야한다는 의미는 아닙니다. 웹 사이트에 대한 모든 코드를 포함하는 클래스 라이브러리 프로젝트를 참조하는 웹 사이트를 가질 수 있습니다. 웹 애플리케이션은이를 수행하는 편리한 방법입니다.

CodeBehind

이 항목은 .aspx 및 .ascx 파일에만 적용됩니다. 이 항목은 코드 숨김 파일을 사용하지 않는 ASP.NET MVC 및 ASP.NET 웹 페이지와 같은 새로운 응용 프로그램 프레임 워크에서 점점 더 관련이 있습니다.

.aspx 페이지 및 .ascx 컨트롤의 코드 숨김 파일을 포함하여 모든 코드 파일을 단일 어셈블리로 컴파일하면 웹 응용 프로그램에서 약간의 변경이있을 때마다 다시 빌드해야하며 실시간으로 변경할 수 없습니다. 웹 사이트를 사용하면 런타임에 변경 사항이 감지되고 페이지 / 컨트롤이 자동으로 재 컴파일되는 동안 변경 사항을 확인하려면 계속 재 구축해야하므로 개발 과정에서 정말 고통 스러울 수 있습니다.

런타임에서 코드 숨김 어셈블리를 관리하도록하는 것은 페이지 / 컨트롤에 고유 한 이름을 부여하거나 다른 네임 스페이스로 구성하는 것에 대해 걱정할 필요가 없기 때문에 덜 효과적입니다.

코드 파일을 배포하는 것이 항상 좋은 생각이라고 말하는 것은 아니지만 (특히 공유 코드 파일의 경우는 아님) 코드 숨김 파일에는 UI 특정 작업, 연결 이벤트 처리기 등을 수행하는 코드 만 포함되어야합니다. 중요한 코드가 항상 Bin 폴더에 있도록 계층화됩니다. 이 경우 코드 숨김 파일을 배포하는 것이 유해한 것으로 간주되어서는 안됩니다.

웹 응용 프로그램의 또 다른 한계는 프로젝트의 언어 만 사용할 수 있다는 것입니다. 웹 사이트에서 일부 페이지는 C #, 일부는 VB 등으로 지정할 수 있습니다. 특별한 Visual Studio 지원이 필요하지 않습니다. 이것이 빌드 공급자 확장 성의 아름다움입니다.

또한 웹 응용 프로그램에서는 컴파일러가 코드 숨김 클래스 만 컴파일하고 런타임에 컴파일되는 마크 업 코드 (MVC에서는 MvcBuildViews 옵션을 사용하여이 문제를 수정할 수 있음)를 컴파일하기 때문에 페이지 / 컨트롤에서 오류 감지를 얻지 못합니다.

비주얼 스튜디오

웹 응용 프로그램은 Visual Studio 프로젝트이기 때문에 웹 사이트에서 사용할 수없는 일부 기능을 사용할 수 있습니다. 예를 들어, 빌드 이벤트를 사용하여 Javascript 파일 축소 및 / 또는 결합과 같은 다양한 작업을 수행 할 수 있습니다.

Visual Studio 2010에 도입 된 또 다른 멋진 기능은 Web.config 변환 입니다.이것은 웹 사이트에서도 사용할 수 없습니다. 이제 VS 2013의 웹 사이트에서 작동합니다.

웹 응용 프로그램을 만드는 것이 웹 사이트를 만드는 것보다 빠릅니다. 이는 주로 웹 응용 프로그램이 마크 업 코드를 컴파일하지 않기 때문입니다. MVC에서 MvcBuildViews를 true로 설정하면 마크 업 코드가 컴파일되고 오류 감지가 발생하므로 매우 유용합니다. 단점은 솔루션을 빌드 할 때마다 전체 사이트를 빌드한다는 것입니다. 이는 특히 사이트를 편집하지 않는 경우 느리고 비효율적 일 수 있습니다. 나는 MvcBuildViews를 켜고 끕니다 (프로젝트 언로드가 필요함). 반면 웹 사이트를 사용하면 솔루션의 일부로 사이트를 구축할지 여부를 선택할 수 있습니다. 선택하지 않으면 솔루션 빌드가 매우 빠르며 변경 한 경우 언제든지 웹 사이트 노드를 클릭하고 빌드를 선택할 수 있습니다.

MVC 웹 응용 프로그램 프로젝트에는 '보기 추가', '보기로 이동', '컨트롤러 추가'등과 같은 일반적인 작업에 대한 추가 명령과 대화 상자가 있습니다. MVC 웹 사이트에서는 사용할 수 없습니다.

IIS Express를 개발 서버로 사용하는 경우 웹 사이트에서 가상 디렉터리를 추가 할 수 있습니다. 이 옵션은 웹 응용 프로그램에서 사용할 수 없습니다.

NuGet 패키지 복원은 웹 사이트에서 작동하지 않으므로 packages.config에 나열된 패키지를 수동으로 설치해야합니다.이제 패키지 복원이 NuGet 2.7을 시작 하는 웹 사이트에서 작동합니다.


웹 사이트 = 그래픽 디자이너가 웹 사이트를 만들고 프로그래머가 한두 페이지 만 편집 할 때 사용

웹 응용 프로그램 = 프로그래머가 응용 프로그램을 만들고 그래픽 디자이너가 하나 또는 두 개의 페이지 / 이미지 만 편집 할 때 사용합니다.

웹 사이트는 개발자 스튜디오 없이도 HTML 도구를 사용하여 작업 할 수 있습니다. 프로젝트 파일을 업데이트 할 필요가 없기 때문입니다. 웹 응용 프로그램은 팀이 대부분 개발자 스튜디오를 사용하고 높은 코드 콘텐츠가있을 때 가장 좋습니다.

(일부 코딩 오류는 런타임까지 웹 사이트에서 발견되지 않는 컴파일 시간에 웹 응용 프로그램에서 발견됩니다.)

경고 : 나는 수년 전에이 답변을 작성했으며 이후 Asp.net을 사용하지 않았습니다. 이제 일이 진행될 것으로 예상합니다.


동적으로 컴파일 된 프로젝트에 대한 특별한 필요 가없는 한 웹 사이트 프로젝트를 사용하지 마십시오 .

왜? 웹 사이트 프로젝트는 프로젝트를 변경하거나 이해하려고 할 때 벽을 위로 올릴 것이기 때문입니다. Visual Studio의 정적 입력 찾기 기능 (예 : 사용 찾기, 리팩터링)은 합리적 크기의 프로젝트에서 모두 영원히 걸립니다. 자세한 내용 은 Visual Studio 의 스택 오버플로 질문 느린 "모든 참조 찾기"를 참조하십시오 .

고통을 유발하고 온전한 상태를 유지하고 생산성을 저하시키는 웹 사이트 프로젝트 유형을 위해 Visual Studio 2005에서 웹 응용 프로그램을 삭제 한 이유를 알 수 없습니다.


차이점을 설명하는 MSDN의 기사가 있습니다.

웹 사이트 프로젝트와 웹 응용 프로그램 프로젝트 비교

BTW : 해당 주제에 대한 유사한 질문이 있습니다. 예 :


이것은 조금 당연하게 들릴지 모르지만 Visual Studio 2005는 원래 웹 사이트와 함께 제공되기 때문에 오해 된 것 같습니다. 프로젝트가 상당히 제한적이고 논리적 또는 물리적 분리가 많지 않은 웹 사이트를 다루는 경우 웹 사이트는 괜찮습니다. 그러나 많은 사용자가 데이터를 추가하고 업데이트하는 서로 다른 모듈이있는 진정으로 웹 응용 프로그램 인 경우 웹 응용 프로그램을 사용하는 것이 좋습니다.

웹 사이트 모델의 가장 큰 장점은 app_code섹션의 모든 것이 동적으로 컴파일 된다는 것입니다 . 전체 재배포없이 C # 파일 업데이트를 수행 할 수 있습니다. 그러나 이것은 큰 희생이 따릅니다. 통제하기 어려운 많은 일들이 커버 아래에서 발생합니다. 네임 스페이스는 제어하기 어렵고 app_code모든 것이 동적으로 컴파일되기 때문에 특정 DLL 사용이 기본적으로 창 밖으로 나갑니다 .

웹 애플리케이션 모델에는 동적 컴파일이 없지만 내가 언급 한 내용을 제어 할 수 있습니다.

n-tier 개발을하고 있다면 웹 애플리케이션 모델을 적극 권장합니다. 제한된 웹 사이트 또는 빠르고 더러운 구현을 수행하는 경우 웹 사이트 모델에 이점이있을 수 있습니다.

더 자세한 분석은 다음에서 찾을 수 있습니다.


MCTS자가 학습 키트 시험 70-515 책에서 발췌 :

웹 애플리케이션 (프로젝트)을 사용하면

  1. MVC 응용 프로그램을 만들 수 있습니다.
  2. Visual Studio는 폴더 구조에 의존하지 않고 프로젝트 파일 (.csproj 또는 .vbproj)에 파일 목록을 저장합니다.
  3. Visual Basic과 C #을 함께 사용할 수 없습니다.
  4. 디버깅 세션을 중지하지 않고 코드를 편집 할 수 없습니다.
  5. 여러 웹 프로젝트간에 종속성을 설정할 수 있습니다.
  6. 배포 전에 응용 프로그램을 컴파일해야합니다. 이렇게하면 다른 페이지가 컴파일되지 않을 경우 페이지를 테스트 할 수 없습니다.
  7. 서버에 소스 코드를 저장할 필요가 없습니다.
  8. 어셈블리 이름과 버전을 제어 할 수 있습니다.
  9. 배포 후 다시 컴파일하지 않고 개별 파일을 편집 할 수 없습니다.

Compilation Firstly there is a difference in compilation. Web Site is not pre-compiled on server, it is compiled on file. It may be an advantage because when you want to change something in your Web Site you can just download a specific file from server, change it and upload this file back to server and everything would work fine. In Web Application you can't do this because everthing is pre-compiled and you end up with only one dll. When you change something in one file of your project you have to re-compile everything again. So if you would like to have a possibility to change some files on server Web Site is better solution for you. It also allows many developers to work on one Web Site. On the other side, if you don't want your code to be available on server you should rather choose Web Application. This option is also better for Unit Testing because of one DLL file being created after publishing your website.

Project structure There is also a difference in the structure of the project. In Web Application you have a project file just like you had it in normal application. In Web Site there is no traditional project file, all you have is solution file. All references and settings are stored in web.config file. @Page directive There is a different attribute in @Page directive for the file that contains class associated with this page. In Web Application it is standard "CodeBehind", in Web Site you use "CodeFile". You can see this in the examples below:

Web Application:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"  
Inherits="WebApplication._Default" %>  

Web Site:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 

Namespaces - In the example above you can see also another difference - how namespaces are created. In Web Application namespace is simply a name of the project. In Website there is default namespace ASP for dynamically compiled pages.

Edit and Continue- In Web Application Edit and Continue option is available (to turn it on you have to go to Tools Menu, click Options then find Edit and Continue in Debugging). This feature is not working in Web Site.ASP.NET MVCIf you want to develop web applications using

ASP.NET MVC (Model View Controller) the best and default option is Web Application. Although it's possible to use MVC in Web Site it's not recommended.

Summary - The most important difference between ASP.NET Web Application and Web Site is compilation. So if you work on a bigger project where a few people can modify it it's better to use Web Site. But if you're doing a smaller project you can use Web Application as well.


It depends on what you are developing.

A content-oriented website will have its content changing frequently and a Website is better for that.

An application tends to have its data stored in a database and its pages and code change rarely. In this case it's better to have a Web application where deployment of assemblies is much more controlled and has better support for unit testing.


Yes web application is much better than web sites, because Web applications give us freedom:

  1. To have multiple projects under one umbrella and establish project dependencies between. E.g. for PCS we can have following within web application-

    • Web portals
    • Notification Controller (for sending Email)
    • Business layer
    • Data Access layer
    • Exception Manager
    • Server utility
    • WCF Services (Common for all platforms)
    • List item
  2. To run unit tests on code that is in the class files that are associated with ASP.NET pages

  3. To refer to the classes those are associated with pages and user controls from standalone classes
  4. To create a single assembly for the entire site
  5. Control over the assembly name and version number that is generated for the site
  6. To avoid putting source code on a production server. (You can avoid deploying source code to the IIS server. In some scenarios, such as shared hosting environments, you might be concerned about unauthorized access to source code on the IIS server. (For a web site project, you can avoid this risk by pre-compiling on a development computer and deploying the generated assemblies instead of the source code. However, in that case you lose some of the benefits of easy site updates.)
  7. Performance Issue with Website(The first request to the web site might require the site to be compiled, which can result in a delay. And if the web site is running on an IIS server that is short on memory, including the entire site in a single assembly might use more memory than would be required for multiple assemblies.)

One of the key differences is that Websites compile dynamically and create on-the-fly assemblies. Web applicaitons compile into one large assembly.

The distinction between the two has been done away with in Visual Studio 2008.


Applications are usually compiled before deployment where as the website makes use of the app_code directory. When anything changes in the app code folder the server will re-compile the code. This means that you can add/ change code with a website on the fly.

The advantage of an app is that there is no re-compiling and so initial start up times will be faster.


I recommend you watch the video Web Application Projects & Web Deployment Projects on the ASP.NET website which explains the difference in great detail, it was quite helpful to me.

By the way, don't get confused by the title, a great part of the video explains the difference between website projects and web application projects and why Microsoft re-introduced Web application projects in Visual studio 2005 (as you probably already know, it originally shipped with only website projects then web application projects were added in SP1). A great video I highly recommend for anyone who wants to know the difference.


A "web site" has its code in a special App_Code directory and it's compiled into several DLLs (assemblies) at runtime. A "web application" is precompiled into one single DLL.


Website and Project>>website are two different methods of creating ASP.NET application using visual studio. One is projectless and another is project environment. Differences are as

  1. Solution file is stored in same directory as root directory in project environment.
  2. Need to remove solution and project files before deploying in project environment.
  3. Complete root directory is deployed in projectless environment.

there no much basic difference in using either approach. But if you are creating website that will take longer time, opt for project environment.


Web Application project model

  • Provides the same Web project semantics as Visual Studio .NET Web projects. Has a project file (structure based on project files). Build model - all code in the project is compiled into a single assembly. Supports both IIS and the built-in ASP.NET Development Server. Supports all the features of Visual Studio 2005 (refactoring, generics, etc.) and of ASP.NET (master pages, membership and login, site navigation, themes, etc). Using FrontPage Server Extensions (FPSE) are no longer a requirement.

Web Site project model

  • No project file (Based on file system).
  • New compilation model.
  • Dynamic compilation and working on pages without building entire site on each page view.
  • Supports both IIS and the built-in ASP.NET Development Server.
  • Each page has it's own assembly.
  • Defferent code model.

It is always depends on the requirement of your client. ASP.NET just includes flexible features that the user needs for security and easy maintenance of your application.

You can think of a Web application as a binary file that runs inside the ASP.NET framework. And Web sites as a static webpage that you can review and easily deploy source code to.

But the advantage and disadvantages of these two ASP.NET technologies come what is good.


Websites - No solution file will be created. If we want to create websites no need for visual studio.

Web Application - A solution file will be created. If we want to create web application should need the visual studio. It will create a single .dll file in bin folder.


In Web Application Projects, Visual Studio needs additional .designer files for pages and user controls. Web Site Projects do not require this overhead. The markup itself is interpreted as the design.


WebSite : It generates app_code folder automatically and if you publish it on the server and after that if you do some changes in any particular file or page than you don't have to do compile all files.

Web Application It generates solutions file automatically which website doesn't generate and if you change in one file than you have to compile full project to reflects its changes.


In a web application you can create the layers of your project's functionality and can create inter-dependencies between them by dividing it into many projects, but you can never do this on a website.


Definitely web application, single DLL file and easy to maintain. But a website is more flexible; you can edit the aspx file on the go.


Web applications require more memory, presumably because you have no choice but to compile into a single assembly. I just converted a large legacy site to a web application and have issues with running out of memory, both at compile time with the error message as below :

Unexpected error writing metadata to file '' -- 
Not enough storage is available to complete this operation. 

error, and at runtime with this error message as below :

Exception information: 
    Exception type: HttpException 
    Exception message: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.Web.Compilation.BuildManager.ReportTopLevelCompilationException()

My recommendation for converting larger sites on memory-constrained legacy hardware is, to choose the option to revert back to the web site model. Even after an initial success problem might creep up later.


Here Web Supportive Application is an example of website.

Here Web Supportive Application is an example of website. Website and Web Application both can be dynamic/static its depends upon requirements, here is an example to understand working of website's and web application.


To summarize some of the answers above:

Flexibility, can you can make live changes to a web page?

Web Site: Possible. Pro: short term benefits. Con: long term risk of project chaos.

Web App: Con: not possible. Edit a page, archive the changes to source control, then build and deploy the entire site. Pro: maintain a quality project.

Development issues

Web Site: Simple project structure without a .csproj file.Two .aspx pages may have the same class name without conflicts. Random project directory name leading to build errors like why .net framework conflicts with its own generated file and why .net framework conflicts with its own generated file. Pro: Simple (simplistic). Con: erratic.

Web App: Project structure similar to WebForms project, with a .csproj file. Class names of asp pages must be unique. Pro: Simple (smart). Con: none, because a web app is still simple.

참고URL : https://stackoverflow.com/questions/398037/asp-net-web-site-or-asp-net-web-application

반응형