本文介绍了ASP.NET如何解决CS1513:}页面上的预期错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在浏览器中查看我的ASP.NET页时,运行时出现错误.我没有收到任何构建错误,但是在运行时出现了以下编译器错误:

I am getting an error at run time when viewing my ASP.NET page in the browser. I am not getting any build errors however I am getting the following compiler error at runtime:

编译错误

描述:在为该请求提供服务所需的资源的编译过程中发生错误.请查看以下特定的错误详细信息,并适当地修改您的源代码.

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

Compiler Error Message: CS1513: } expected

Source Error:


Line 329:            #line hidden
Line 330:            __output.Write("\r\n\t\t\t</div>\r\n\t\t");
Line 331:        }
Line 332:
Line 333:        private System.Web.UI.Control __BuildControl__control7() {

Source File: c:\Windows\Microsoft.NET\Framework\v1.1.4322\
    Temporary ASP.NET Files\xxxxxxxx\450ffa78\d46d847d\
    k1gsz9dj.0.cs    Line: 331

我无法在源代码中找到任何缺少的},并且在ASP.NET临时文件目录中存在的生成的代码文件中发生了此错误.如何将其追溯到页面或页面上的用户控件中实际存在错误的代码行?

I cannot locate any missing } in my source code and this error is occurring in the generated code files that exist in the Temporary ASP.NET Files directory. How can I trace this to the line of code that is actually malformed in my page or user controls on my page?

推荐答案

如果错误代码与以下内容有关:

If the error code related as following:

与保留字相同的变量名称,然后可以重命名变量.

A variable name same as reserved word then you can rename variable.

代码段,例如:

@model MyModel
{
    var appname = @Model.Apps.FirstOrDefault(x => x.ID == Model.SelectedApp);
}

删除Model.Apps.FirstOrDefault(x => x.ID == Model.SelectedApp)之前的'@'

代码段或节的用法,例如:

A code segment or section usage such as:

@section{
    <!-- hiiii it's not about an error -->
}

从该节的注释中删除撇号.

Remove the apostrophe from comment in section.

如果不是所有这些特定情况,您都可以尝试通过应用源减少来查找产生错误的位置.删除/剪切/注释掉部分代码,直到您可以可靠地关闭和打开该错误为止.如果不是上述情况之一,则可能是导致错误打开的代码.

If it is none of these specific cases you can attempt to locate where the error is generated by applying a source reduction. Delete/cut/comment out pieces of code until you can reliably turn the error off and on. The code that turns the error on is likely the culprit if it is not one of the above situations.

这篇关于ASP.NET如何解决CS1513:}页面上的预期错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 04:24