None of my “code behind” code is being called

前端 未结 9 2054
予麋鹿
予麋鹿 2021-02-08 00:40

I have just created an ASP.NET C# project and a virtual directory for it in IIS in (as far as I know) the normal way, but I am seeing very strange behavior that I have never see

9条回答
  •  轮回少年
    2021-02-08 01:01

    Try changing :

    <%@ Page Language="C#" AutoEventWireup="false" CodeBehind="Default.aspx.cs" Inherits="Drawings2._Default" %>
    

    to:

    <%@ Page Language="C#" AutoEventWireup="false" CodeFile="Default.aspx.cs" Inherits="Drawings2._Default" %>
    

    The CodeBehind is for visual studio. I believe CodeFile is used for the JIT.

    The other alternative is to compile your project and update your assembly in the bin dir.

    http://msdn.microsoft.com/en-us/library/ydy4x04a.aspx

    CodeBehind 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. For more information about Web project types in Visual Studio, see Web Application Projects versus Web Site Projects.

    CodeFile Specifies a path to the referenced code-behind file for the page. This attribute is used together with the Inherits attribute to associate a code-behind source file with a Web page. The attribute is valid only for compiled pages.

    This attribute is used for Web site projects.

    The CodeBehind attribute is used for Web application projects. For more information about Web project types in Visual Studio, see Web Application Projects versus Web Site Projects.

提交回复
热议问题