简体   繁体   English

ASP.NET构建-Bin文件夹与CodeBehind文件

[英]ASP.NET Build - Bin Folder vs CodeBehind File

Assume there is a asp.net 4.0 web application and it has a default.aspx and default.aspx.cs files in it. 假设有一个asp.net 4.0 Web应用程序,并且其中包含default.aspx和default.aspx.cs文件。 After I build the project, a dll that is named of the project created in the bin folder. 构建项目后,将在bin文件夹中创建的项目命名为dll。 So what the dll contains ? 那么dll包含什么? All code behind files compiled versions ? 文件编译版本后的所有代码?

If the aspx files still refers its CodeBehind file like below, then does the dll used for this aspx file or still code behind is valid to run the project ? 如果aspx文件仍然像下面一样引用其CodeBehind文件,那么用于此aspx文件的dll还是后面的代码是否有效即可运行项目?

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WebApplication3._Default" %>

In a Web Application , all your C# code is contained within the DLLs in the bin directory. Web应用程序中 ,所有C#代码都包含在bin目录的DLL中。 There are a couple of exceptions, such as DLLs that you rely on that live in the GAC, for example. 有几个例外,例如,GAC中存在的依赖的DLL。 Using a web application ( your question says this is what you are using ), you do not need to deploy your *.cs code behind files. 使用Web应用程序(您的问题说这就是您正在使用的东西),您不需要在文件后面部署* .cs代码。

A Web Site is different. 网站是不同的。 Changes are detected and recompiled on the fly. 可以检测到更改并即时对其进行重新编译。 You'll need to include your C# files code-behind files when creating a Web Site type project. 创建网站类型项目时,您需要在代码后的文件中包含C#文件。

ASP.NET Web Site or ASP.NET Web Application? ASP.NET网站还是ASP.NET Web应用程序?

A DLL is a library that contains code and data that can be used by more than one program at the same time: DLL是一个库,其中包含可同时由多个程序使用的代码和数据:

What is a DLL? 什么是DLL?

Code-behind refers to code for your ASP.NET page that is contained within a separate class file. 隐藏代码是指包含在单独的类文件中的ASP.NET页面的代码。 This allows a clean separation of your HTML from your presentation logic: 这样可以将HTML与表示逻辑完全分开:

ASP.NET Code-Behind Model Overview ASP.NET代码隐藏模型概述

The code gets compiled into the assembly produced by your web project. 该代码被编译到Web项目生成的程序集中。 You can change its name and default namespace as part of project options. 您可以在项目选项中更改其名称和默认名称空间。

As I understood it, the ASPX file is only used IF the project is marked as being updatable, otherwise it is just a placeholder file. 据我了解,仅当项目被标记为可更新时,才使用ASPX文件,否则它只是一个占位符文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM