Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

understanding asp.net code behind

Posted on 2006-06-13
3
Medium Priority
?
419 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 1200 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 800 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 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