views:

211

answers:

2

My view has errors. I see these errors only if I open the view in Visual Studio.

I would like to see the errors on compile time rather than on execute time.

Does exist a way to obtain this behavior?

A: 

I assume you are talking about C# compile errors and not things like CSS validation errors.

One thing you can do is add a Web Deployment Project to your solution. When it builds, it will run aspnet_compiler.exe on your project which will expose any of these C# compile errors in .aspx files that otherwise wouldn't be indicated until the .aspx file was compiled on the fly at runtime.

Erv Walter
+4  A: 

You can update by hand the .csproj file and add a <MvcBuildViews>true</MvcBuildViews> that will compile the views as you go.

Here's a link I googled, you'll find others as well.

EDIT: If it's too slow try setting the build only for Release, edit the csproj file doing something like this; see the docs for AspNetCompiler for more details.

<!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
   Other similar extension points exist, see Microsoft.Common.targets.
   -->
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
    <AspNetCompiler VirtualPath="Temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
</Target>
Scott
It works but it's slooooooooow!!
Ricibald
You might consider creating a separate build, or using Release, and turning it off for Debug builds. See edit above.
Scott
you can also use Resharper
Ricibald