-
Since all files in a web project are compiled into single assembly, then does this assembly maintain a directory structure? For example, if a file in a root directory references a file in a subdirectory, then how could this reference still be valid when the two files get compiled into same assembly?
-
Assume a web project has the directory structure shown below.
Since all of web project’s ASPX files get compiled into a single assemblyWebProject1.dll
, how is this assembly able to record/memorize the directory structure?
Thus, when you deployWebProject1.dll
to a web server and user makes a request forhttp://WebProject1/some_SubDir/default.aspx
, how willWebProject1.dll
be able to figure out which Page to render?WebProject1\SubDir (where WebProject1 is a root directory)
WebProject1 — contains several ASPX files
WebProject1\SubDir — contains a filedefault1.aspx
. -
When we deploy the Web project, must we create the same directory structure on a web server (
WebProject1\SubDir
), even though we won’t put any ASPX files into those directories? -
I assume that on Web server
WebProject1.dll
should be placed into theBin
directory?
thanx
EDIT:
Only the sourcecode is compiled into the assembly, you still need to upload the aspx files into a matching directory on the server.
My book says that when using Web project all web code is compiled into single assembly. I thought “all code” includes aspx files?!
Links are maintained between the page and it's code behind file through a class declaration which by default is in a namespace that matches the directory structure
So if I add a new aspx page via Project –> Add New Item, and store this aspx page in a subdirectory named Hey, then this page will reside in namespace WebProject1.Hey?!
But how do I do add new item into a subdirectory, since Project –> Add New Item doesn’t give me an option to browse and choose a directory I wish to save it in, but instead automatically creates aspx file in a root directory?
The relative path is kept when the compiler generate the dll.
I’m not sure I know what relative path you’re referring to?
thanx
Best Answer
Only the sourcecode is compiled into the assembly, you still need to upload the aspx files into a matching directory on the server. For example you project in Visual Studio may look like the following:
Once you have compiled the web app you'll need to upload the following to the server:
Compiled resources (non-sourcecode files that are compiled and stored inside the assembly) are different issue that are addressed in your other question
Edited to add direct answers to the questions:
Not all files are compiled into the assembly, only source code files are. Links are maintained between the page and it's code behind file through a class declaration which by default is in a namespace that matches the directory structure, but it doesn't have to be.
Your default1.aspx file will have in the header something like:
The inherits line tells the webserver that when a user requests this page it should be processed in conjunction with the source code that defines that class, which it will find inside the compiled assembly. The combination of the physical aspx file and the compiled class will generate standard html which is then passed back to the client.
Yes, you need to create the same directory structure, but you are required to put the aspx files in there.
Yes
(can someone please edit this if they know how to get the list items to number correctly, please?)