C# – Build does not catch errors in the View in asp.net mvc

asp.netasp.net-mvccdebugging

Why don't we get compile errors on inline code errors in asp.net mvc views f.eks

<h1><%= ViewData.Model.Title.Tostrig() %></h1>

The code above will build just fine. Wrong spelling in webform controls will give you an error so I can't see why this isn't supported in asp.net mvc

EDIT:
Luckily there seem to be a fix included in the first RC for asp.net mvc
http://weblogs.asp.net/scottgu/archive/2008/12/19/asp-net-mvc-design-gallery-and-upcoming-view-improvements-with-the-asp-net-mvc-release-candidate.aspx

Best Answer

The ASPX files in both ASP.NET and ASP.NET MVC are not compiled from the Visual Studio IDE. This is often the cause for "false positives" as you have pointed out.

I often add the aspnet_compiler as a post build action to find those errors. You will add some time to your build process, but in exchange for the wait you should be able to spot these errors more easily.