After upgrading an ASP.NET MVC 3 project to ASP.NET MVC 4, my page failed to load with the following error message:
HttpParseException: Unexpected "this" keyword after "@" character.
Here is the failing code block. The exception occurs on line 5:
This seems to be a bug in Razor V2 as mentioned here: http://aspnetwebstack.codeplex.com/workitem/458. The ASP.NET team decided not to fix this, so you have to use a workaround.
By adding some extra ‘()’ the error goes away: