且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET如何解决CS1513:}页面上的预期错误

更新时间:2023-12-03 10:16:16

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

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.