35

It's really annoying that visual studio hides typos in aspx pages (not the code behind). If the compiler would compile them, I would get a compile error.

Shog9
  • 156,901
  • 35
  • 231
  • 235
Paco
  • 8,335
  • 3
  • 30
  • 41

5 Answers5

27

Compile the pages at compile time. See Mike Hadlow's post here:

http://mikehadlow.blogspot.com/2008/05/compiling-aspx-templates-using.html

Iain Holder
  • 14,172
  • 10
  • 66
  • 86
11

Go to your project properties. Go to the Build Events tab.

In the Post-build event command line: text area, write this (for .NET 4.0):

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -v / -p "$(SolutionDir)$(ProjectName)"
Community
  • 1
  • 1
Alex Rouillard
  • 777
  • 8
  • 9
4

Resharper will catch errors in code ofASPX pages, all without compiling. works well imo, and better than later compiling.

EDIT: Resharper also has a Solution wide error checker. 'Resharper->Windows->Errors in solution'. It will analyze your entire solution and give a consolidated list of everything it finds, INCLUDING aspx files.

mattlant
  • 15,384
  • 4
  • 34
  • 44
  • 1
    Resharper does catch the errors, but only when the file is opened. – Paco Sep 20 '08 at 15:05
  • But you need to create and edit the first, which means you should catch the error. – mattlant Sep 20 '08 at 15:10
  • 3
    What if you delete a property from a model, and reference it in your view as <% = ViewData.Model.DeletedProperty %> your code compiles, but your page is broken... – Casper Sep 20 '08 at 15:11
  • If that wont suffice, then you could always do a full precompile. – mattlant Sep 20 '08 at 15:11
1

It is my belief you should always compile ASP.NET applications. There are a few instances where my clients requested otherwise. In Visual Studio, when you choose to publish your website, there is an option to have it compiled. Here is Microsoft's MSDN article which offers their information on compiling sites.

http://msdn.microsoft.com/en-us/library/ms178466.aspx

HTML issues and such will show up as "warnings" and not errors. So, you'll have to check the logs.

stephenbayer
  • 12,373
  • 15
  • 63
  • 98
0

There is the possibility to precompile the whole web: usually the pages only get compiled, if they are used.

To precompile the web, please refer to MSDN

MADMap
  • 3,132
  • 3
  • 25
  • 31