错误:'/'应用程序分析器错误中的服务器错误,asp.net c#?

Sar*_*nya 0 c# asp.net

在我的应用程序中,其他页面正在正常运行,但此页面引发了错误.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OutReport.aspx.cs" Inherits="HMS.OutReport" MasterPageFile="~/Site.Master" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
</asp:Content>
Run Code Online (Sandbox Code Playgroud)

错误

Server Error in '/' Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service     this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: Could not load type 'HMS.OutReport'.

Source Error: 


Line 1:  
Line 2:  <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OutReport.aspx.cs"     Inherits="HMS.OutReport" MasterPageFile="./Site.Master" %>
Line 3:  <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
Line 4:  </asp:Content>

Source File: /OutReport.aspx    Line: 2 
Run Code Online (Sandbox Code Playgroud)

Mic*_* DN 7

尝试CodeBehind="OutReport.aspx.cs"改为CodeFile="OutReport.aspx.cs"

编辑:

一个代码隐藏需要编译(asp.net 1.1模式)和编译的二进制被放置在网站的bin文件夹.在部署之前,您需要在visual studio中进行编译.当您不希望源代码可以作为纯文本查看时的良好模型...例如,当交付给您没有义务提供代码的客户时.

一个的CodeFile文件位于由ASP.NET运行时编译需求.您可以"预编译"您的网站以回退到较旧的模型,如果您不想将源代码部署到每个网站,这将非常有用.但默认情况下,您的CodeFile文件是部署到站点的.cs文件,该类是在ASP.NET临时存储文件夹中生成的.

在您的代码中,您告诉ASP.NET忽略C#文件的存在,并且只在已编译的程序集中查找它.反过来,ASP.NET告诉您编译的程序集实际上并不包含您告诉它要查找的类.