C# 解析器错误消息:文件“/TestSite/Default.aspx.cs”不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/538719/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Parser Error Message: The file '/TestSite/Default.aspx.cs' does not exist
提问by EKS
Short story. This site was created by a friend of mine, who did not know that much C# or asp. And was firstly created in VS 2k3. When i converted it to VS 2k8 these errors started to crop up, there was also other issues with compiling that i managed to sort out ( Seemed to be released to VS 2k8 wanted design files )
短篇故事。这个网站是由我的一个朋友创建的,他对 C# 或 asp 一无所知。并且最初是在 VS 2k3 中创建的。当我将它转换为 VS 2k8 时,这些错误开始出现,还有其他编译问题我设法解决了(似乎已发布到 VS 2k8 想要的设计文件)
Error message gotten:
得到的错误信息:
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: The file '/TestSite/Default.aspx.cs' does not exist.
Source Error:
Line 1:
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="GuildStats._Default" %>
Line 2:
Line 3:
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
解析服务此请求所需的资源期间发生错误。请查看以下特定解析错误详细信息并适当修改您的源文件。
解析器错误消息:文件“/TestSite/Default.aspx.cs”不存在。
源错误:
第 1 行:
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="GuildStats._Default" %>
第 2 行:
第 3 行:
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
Defaults.aspx.cs
默认值.aspx.cs
namespace GuildStats
{
public partial class _Default : System.Web.UI.Page
{
Defaults.aspx
默认值.aspx
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="GuildStats._Default" %>
Site.master.cs
网站管理员.cs
namespace GuildStats
{
public partial class Site : System.Web.UI.MasterPage { }
}
Site.master
网站管理员
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="GuildStats.Site" %>
采纳答案by Bravax
In Default.aspx
change CodeFile
to CodeBehind
. You'll probably have to do the same for the Site.master
.
在Default.aspx
更改CodeFile
为CodeBehind
. 您可能必须对Site.master
.
请参阅:代码文件和代码隐藏
回答by Kiki
Web Site projects use CodeFile, Web Application projects use CodeBehind. CodeFile requires the source file, it is compiled on the fly when the page is loaded, CodeBehind requires the compiled code.
网站项目使用 CodeFile,Web 应用程序项目使用 CodeBehind。CodeFile 需要源文件,它在页面加载时即时编译,CodeBehind 需要编译后的代码。
My guess is that your problem was created when you changed your project type from a WebApp to a Web Site or vice-versa. If you do this, you have to manually change the directives in the existing files, new files will have the right directive automatically.
我的猜测是您的问题是在您将项目类型从 WebApp 更改为网站时产生的,反之亦然。如果这样做,您必须手动更改现有文件中的指令,新文件将自动具有正确的指令。