Solved

understanding asp.net code behind

Posted on 2006-06-13
3
413 Views
Last Modified: 2013-11-25
Hi

I want to clarify my understanding of asp.net code behind. I am going to write down my understanding. I would appreciate it if you could correct bits or add on bits I am missing.

Code behind doesnt mean anything to the asp.net engine. It is something specific to Visual Studio. It tells VS where the code behind for a web page is.

When you make solution in VS all of the vb files are compiled into a dll and put in the application bin directory.
When you put this on the website, the asp.net engine looks for all classes it needs in the dlls in the bin directory
Will it look in all the dlls in the bin directory?
Does it look anywhere else?

When you have a dll you dont need to upload the vb files. In fact, when you have a dll you shouldnt upload the vb files because they take precedence and the asp.net engine will compile the vb files every time the application starts and ignore the dll

If you upload the vb files and not a dll, the asp.net engine will compile the vb files dynamically into a dll every time it runs the application.

However, I DONT UNDERSTAND THIS:
I was experimenting with my website and I deleted the dll. If what I have said is correct, asp.net should have compiled all the vb files into a dll and the application should have run ok. However, it didnt and I got a could not load type message. Why is this????

You can use the code behind model without visual studio. YOu can give asp pages a src attribute which tells asp.net where to look for the class file

If you use a src attribute, does the asp.net engine compile the vb files into a dll? I dont think it does. I believe if you want to compile the files you need to use the vbc compiler.


Any comments to add to  my understanding are welcomed

thanks
andrea
0
Comment
Question by:andieje
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 300 total points
ID: 16895017
>> Will it look in all the dlls in the bin directory?
Yes.

>> Does it look anywhere else?
It will look in the GAC if it doesn't find it in /bin. It may look in other paths that you specify in your config (at least, it will with .Net 2.0).

>> If you upload the vb files and not a dll, the asp.net engine will compile the vb files dynamically into a dll every time it runs the application
You shouldn't upload the .vb files. The ASP.Net engine will compile the IL code stored in the DLL using the JIT compiler the first time it is run. The DLL has to be present on the server, the ASP.Net engine will not compile your .vb files.

>> You can use the code behind model without visual studio. YOu can give asp pages a src attribute which tells asp.net where to look for the class file
True. But trying to do it freehand is more trouble than its worth.
0
 
LVL 25

Accepted Solution

by:
dstanley9 earned 200 total points
ID: 16895038
Here's an MSDN article from Fritz Onion (who knows what he's talking about):

http://msdn.microsoft.com/msdnmag/issues/06/01/ExtremeASPNET/

To answer your specific question:

Unless you're using the SRC attribute, ASP.NET will need to compiled DLLs to acquire the type that the page inherits from (even if the source code is there).  If you use the SRC attribute, it will compile the source on-the-fly (NOT into a static DLL) and load the types from the assembly in memory.  There may be some caching involved so that it doesn't re-compile unless there's a change in the source code, but I don't have first-hand knowledge of that.
0
 
LVL 25

Expert Comment

by:dstanley9
ID: 16895043
Sorry, that should be:

ASP.NET will need THE compiled DLLs to aqcuire...
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question