ASP.NET - Inline / Code Behind

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
 
C

Cowboy \(Gregory A. Beamer\)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top