Exception in AspnetMvc with Razor: Parser Error Message: Expected “}”.
The below text/error can occur if you have missed one of the } in jquery in a @section features{ section.
It can be hard tracking exactly which } is missing because commenting out the javascript code doesn’t change anything – it seems the razor engine doesn’t care about that type of comments. Instead start the @section{} anew and copy-paste the code in again piece by piece.
In my case it was a totally ok javascript for loop:
for (i = 0 ; i < 12 ; i++) { }
Server Error in ‘/myApplication’ 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: Expected “}”.
Source Error:
Line 204: </p>
Line 205: </section> Line 206:</section> |
I’ve had this same bug. It is a crazy Razor bug.
Stupid Razor considers the “<" symbol as an opening angle bracket. We can fool him, closing brackets after comment:
for (i = 0 ; i
It works! :)
And stupid parser cut my comment:
for (i = 0 ; i
OMG! Conspiracy of parses…
for (i = 0 ; i < 12 ; i++) { } // >
nice!