Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.net Web Forms, get aspx/view errors at compile time?

I know this can be done with mvc2, but is there any way for visual studio(2010)/resharper(6) to check for errors on aspx pages at compile time and halt the build? Resharper can detect the errors just fine, so it seems like there should be a way to integrate a check of all the aspx pages in to the build process.

Any tips?

like image 209
jdc0589 Avatar asked Jul 07 '11 15:07

jdc0589


People also ask

Does ASPX need to be compiled?

aspx. cs file) must first be compiled. This compilation can happen explicitly or automatically. If the compilation happens explicitly then the entire application's source code is compiled into one or more assemblies ( .

What is ASPX and ASPX CS?

aspx. cs code is run server side, while the . aspx file is compiled on the server and is then served to the web client requesting it. Additionally, for MVC, I would suggest using a different view model, specifically Razor, which uses .

What are .aspx files explain code behind class file in detail?

If you use code-behind class files with . aspx pages, you can separate the presentation code from the core application logic (or code-behind). The code-behind class file is compiled so that it can be created and used as an object. This allows access to its properties, its methods, and its event handlers.


1 Answers

Yes you can. The following steps will cause .aspx files to be compiled as part of a normal builk invoked by the IDE, no Resharper plugin required.

  • Unload your web app (right click on the project and select ‘Unload Project’)
  • Open the .csproj file in a text editor (right click on the project and select ‘Edit myProjectName.csproj’)
  • At the bottom of the file find the comment which says ‘To modify your build process…’ and insert the following after that comment:

<Target Name="AfterBuild"><AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" /></Target>

Source - Compile Aspx pages at compile time using the AspNetCompiler build task

like image 81
Justin Avatar answered Sep 18 '22 03:09

Justin