Let's assume my ASPX page has no inline C# code blocks.
So, I can safely set
<pages compilationMode="Never" />
...in my web.config file and not worry about compilation errors.
Performance-wise, would there be any penalty to using the following setting?
<pages compilationMode="Auto" />
i.e. does the "auto" detection take any significant amount of time?
The impact of Auto appears to be very little. (Although obviously more than Never).
If we examine the code in System.Web.UI.TemplateParser, we see in
ImportSourceFile
that process is aborted early if mode is set toNever
:Which is of course helpful, and definitely the lowest-impact. However, continuing through the routines in
TemplateParser
, we can see inParseStringInternal
the parser literally scans the loaded template searching for variations of<%
:Note the
BaseParser.aspCodeRegex
, which is an instance of this pattern:If it encounters none, it simply moves on. The searching is a fairly inexpensive operation - the biggest hit is when code blocks are actually found, compiling them.