gpt4 book ai didi

c# - "codebehind"和 "source"之间的区别

转载 作者:太空狗 更新时间:2023-10-29 17:50:44 24 4
gpt4 key购买 nike

任何人都可以通过示例告诉我 Codebehind="MyCode.aspx.cs"Src="MyCode.aspx.cs" 之间的区别是什么?

最佳答案

代码隐藏

Specifies the name of the compiled file that contains the class associated with the page. This attribute is not used at run time. This attribute is used for Web application projects. The CodeFile attribute is used for Web site projects.

Needs to be compiled ( asp.net 1.1 model) and compiled binary is placed in the bin folder of the website. You need to do a compile in visual studio before you deploy. Good model when you do not want the source code to be viewable as plain text ... for example when delivering to a customer who you not have obligation to provide code.

来源

Specifies a path to a source file containing code that is linked to the page. In the linked source file, you can choose to include programming logic for your page either in a class or in code declaration blocks.

You can use the Src attribute to link build providers to the page. For more information, see the BuildProvider class. Also, in versions of ASP.NET prior to 2.0, the Src attribute was used as an alternative way to link a code-behind file to a page. In ASP.NET 2.0, the preferred approach to linking a code-behind source file to a page is to use the Inherits attribute to specify a class, along with the CodeFile attribute to specify the path to the source file for the class.

You provide the source file with the solution for deployment. ASP.NET 2.0 runtime compiles the code when needed. The compiled files are at Microsoft.NET[.NET version]\Temporary ASP.NET Files.

始终建议先查看官方文档。查看msdn documentation对于这个问题。

关于c# - "codebehind"和 "source"之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20542714/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com