4

Is it possible to have Visual Studio check .aspx pages for errors when compiling? For example, if I have a Web Form with this control:

<asp:Button ID="CancelButton" runat="server" OnClick="CancelButton_Click" Text="Cancel" />

If CancelButton_Click does not exist in the code behind, have VS throw an error when compiling the application. Currently it still compiles, but throws an error at run time. Is this possible? I realize compile time would greatly increase, but it would be helpful catching problems before run time. I thought I read about the ability to do this with Asp.Net MVC views, but cannot find the link.

mxmissile
  • 11,464
  • 3
  • 53
  • 79
  • see: http://stackoverflow.com/questions/108405/how-can-i-compile-asp-net-aspx-pages-before-loading-them-with-a-webserver – mcfea May 09 '13 at 16:26

1 Answers1

4

Yes you have to compile using a deployment project and uncheck "allow this site to be updatable" This compiles just about everything except for a few minor edgecases like xml-serialization.

As you have discovered, when you compile with F5, you are really only compiling about half of your code and the rest compiles on first request.

MatthewMartin
  • 32,326
  • 33
  • 105
  • 164