Over the last couple of days I’ve started playing around with the razor view engine that comes with ASP.NET MVC 3. The first thing you notice is how much cleaner your markup pages look. It’s a real pleasure to code your markup without having to pollute it with masses of special code nuggets to demarcate your C# code. If you haven’t seen any examples yet check out Scottgu’s intro to Razor.
The error reporting still looks like it could do with a little work though. For example yesterday I put code very similar to this in my view:
@for(int i = 0; i < 5; i++) { <p>@i.ToString()</p> @}
And I got an error message like this:
Humm… “No overload for method ‘Write’ takes 0 arguments” – what does that mean? Well the answer is that the @ symbol before the closing curly brace isn’t needed. So the fix was simply to make the following change:
@for(int i = 0; i < 5; i++) { <p>@i.ToString()</p> }
I guess once you’ve used razor for even a short while things like this will become second nature, but it had me stumped for a short time and it’d be nice if the error messages due to view engine parser failures were slightly more helpful in identifiying the exact problem.
Pingback: asp.net, c#,javascript