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