ASP.NET Web Site or ASP.NET Web Application?

前端 未结 25 2301
自闭症患者
自闭症患者 2020-11-21 08:26

When I start a new ASP.NET project in Visual Studio, I can create an ASP.NET Web Application or I can create an ASP.NET Web Site.

What is the difference between ASP.

相关标签:
25条回答
  • 2020-11-21 08:49

    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.

    0 讨论(0)
  • 2020-11-21 08:50

    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.

    0 讨论(0)
  • 2020-11-21 08:50

    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.

    0 讨论(0)
  • 2020-11-21 08:52

    Unless you have a specific need for a dynamically compiled project, don't use a web site project.

    Why? Because web site project will drive you up the wall when trying to change or understand your project. The static typing find features (e.g. find usages, refactor) in Visual Studio will all take forever on any reasonably sized project. For further information, see the Stack Overflow question Slow “Find All References” in Visual Studio.

    I really can't see why they dropped web applications in Visual Studio 2005 for the pain-inducing, sanity-draining, productivity carbuncle web site project type.

    0 讨论(0)
  • 2020-11-21 08:52

    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.
    0 讨论(0)
  • 2020-11-21 08:52

    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.

    0 讨论(0)
提交回复
热议问题