ASP.NET MVC Razor View: The code block is missing a closing "}" character

by Oliver 13. June 2013 15:17

Some part of MVC 4 didn't like what was in my view:

   1: @using Orchard.ContentManagement;
   2: @using Orchard.Users.Models;
   3: @{
   4:     var userCanRegister =
   5:         @WorkContext.CurrentSite.As<RegistrationSettingsPart>().UsersCanRegister;
   6:     var enableLostPassword = 
   7:         @WorkContext.CurrentSite.As<RegistrationSettingsPart>().EnableLostPassword;
   8: }

Turns out that the (incorrectly placed) @ signs in front of WorkContext were (finally) not swallowed silently anymore. Now, this works:

   1: @using Orchard.ContentManagement;
   2: @using Orchard.Users.Models;
   3: @{
   4:     var userCanRegister =
   5:         WorkContext.CurrentSite.As<RegistrationSettingsPart>().UsersCanRegister;
   6:     var enableLostPassword =
   7:         WorkContext.CurrentSite.As<RegistrationSettingsPart>().EnableLostPassword;
   8: }

It's just the error message that's a bit misleading.

enjoyed the post?

Tags:

ASP.NET | MVC

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

About Oliver

shades-of-orange.com code blog logo I build web applications using ASP.NET and have a passion for javascript. Enjoy MVC and Orchard CMS, and I do TDD whenever I can. I like clean code. Love to spend time with my wife and our three children. My profile on Stack Exchange, a network of free, community-driven Q&A sites

About Anton

shades-of-orange.com code blog logo I'm a software developer at teamaton. I code in C# and work with MVC, Orchard, SpecFlow, Coypu and NHibernate. I enjoy beach volleyball, board games and Coke.