Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I compile Asp.Net Aspx Pages before loading them with a webserver?

Tags:

asp.net

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.

like image 562
Paco Avatar asked Sep 20 '08 15:09

Paco


People also ask

Does ASPX need to be compiled?

In order for the ASP.NET engine to service a request for this page, the page's code portion (the WebPage. aspx. cs file) must first be compiled. This compilation can happen explicitly or automatically.

Are ASPX pages compiled?

By default, ASP.NET Web pages and code files are compiled dynamically when users first request a resource, such as an ASP.NET page (. aspx file), from a Web site.

What ASP.NET deployment method is used to Precompile Web site content before installation?

Performing Precompilation You can precompile a Web site using the Aspnet_compiler.exe tool on the command line. For more information, see How to: Precompile ASP.NET Web Sites for Deployment and ASP.NET Compilation Tool (Aspnet_compiler.exe). Visual Studio also includes commands to precompile a Web site from the IDE.


2 Answers

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

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

like image 53
Iain Holder Avatar answered Sep 18 '22 19:09

Iain Holder


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)" 
like image 22
Alex Rouillard Avatar answered Sep 21 '22 19:09

Alex Rouillard