ASP.NET - Inline / Code Behind

  • Thread starter Thread starter Shiva Ramani
  • Start date Start date
S

Shiva Ramani

Though there are several blogs/Q&A's on inline or codebehind debate, I would
like to know the compilation model or the process thats happenign when we use
Inline or code behind in ASPX. Would it be right to say Inline and
code-behind code are executed on the Web server. Inline code is JIT compiled
at run time and code-behind code is precompiled.

Thanks
 
On a very high level, normal situation basis, you are somewhat on track
(sans your terminology), as the CodeBehind is compiled to assemblies, while
more of the steps are done on the server with inline. If you use publish
before pushing out bits, however, they can both be essentially precompiled,
although the inline makes it a bit easier to edit production (which is a bad
idea, BTW).

Both types of code are JITted into memory at the time of first hit, so there
is a compilation step beyond IL. Inline code also has to be turned into IL,
so there is a potential of a bit of an extra hit. You can avoid much of the
first hit lag with precompile.axd.

Overall, neither code behind nor inline is a great option for actually
working code, as you should have a clean separation of concerns (UI and
business logic). If you follow this "rule" (ie, putting your working code
into libraries), it should not really make much of a difference whether you
inline or code behind, although having the precompilation to IL also makes
it harder to get at your code (at least in theory) and gives you the option
of obfuscation.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
 
Back
Top