Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET how to resolve CS1513: } expected error on page

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:

Compilation Error

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 

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?

like image 254
Tiger Avatar asked Feb 23 '12 03:02

Tiger


Video Answer


1 Answers

Look in the markup (aspx or ascx) for blocks like:

<% ... some C# code.... { %>

   markup(controls, html etc)

<% } %>

Any opened bracket { needs to be closed with another bracket }.

These pages or controls are compiled once by ASP .Net when they are first requested. Visual Studio doesn't compile aspx or ascx files.
If the project is "Web Site" type, Visual Studio compiles the aspx/ascx files, but if the project is "Web Application" type Visual Studio doesn't "compile" the markup (it does not generate the corresponding classes to the aspx/ascx markup)

like image 116
Adrian Iftode Avatar answered Oct 16 '22 07:10

Adrian Iftode