CodeBehind
指定包含與頁關聯的類的已編譯文件的名稱。該屬性不能在運行時使用。
Specifies the name of the compiled file that contains the class associated with the control. This attribute is not used at run time.網站
指定包含與頁關聯的類的已編譯文件的名稱,編譯完後全部cs中的代碼打包進dll.該屬性不能在運行時使用.提供此屬性是爲了與之前版本的 ASP.NET 的兼容,以實現代碼隱藏功能。spa
CodeFile
指定指向頁引用的代碼隱藏文件的路徑。此屬性與 Inherits 屬性一塊兒使用能夠將代碼隱藏源文件與網頁相關聯。此屬性僅對編譯的頁有效。好比VS2005中新建一個網站你會發現編譯比WEB應用程序慢不少,可是能夠修改代碼後不用總體編譯刷新頁面就能夠看到效果.
Specifies a path to the referenced code-behind file for the control. This attribute is used together with the Inherits attribute to associate a code-behind source file with a user control. The attribute is valid only for compiled controls..net
我這裏碰到的狀況就是,整個Web 項目被編譯成了組件,可是 ASPX 頁面有以下的定義:
<%@ Page CodeFile="***" Inherits="***" %>
這時候,ASP.net 就須要找 CodeFile 中指定的文件,以便動態編譯,可是找不到,因此就報上述錯誤了。code
對於開發時,即 頁面的邏輯代碼 cs 文件存在的時候,下屬兩種寫法都沒有問題。
<%@ Page Language="C#" AutoEventWireup="true" Codebehind="index.aspx.cs" Inherits="Community.IndexHomePage.index" %>blog
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="Community.IndexHomePage.index" %>
可是部署到站點後,咱們不會部署 cs 文件,這時候,後一種寫法就會報找不到文件的錯誤了。除非你把 cs 也部署出去,不然就會報編譯時錯誤,找不到文件...ci