understanding asp.net code behind
Posted on 2006-06-13
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