eramgarden Posted September 28, 2006 Posted September 28, 2006 I was reading this tutorial: http://www.asp.net/learn/dataaccess/tutorial02vb.aspx?tabid=63 He has :In a real-world application, the BLL should be implemented as a separate Class Library project; however, for these tutorials we'll implement the BLL as a series of classes in our App_Code folder in order to simplify the project structure I know we want to have a 3-tier design. At my last job, it was .net 1.1, the vendor had 3 projects in the solution and they used "Visual Basic Building Blocks/BusinessFacade/dataAccess" etc. They had 3 projects one with "common" functionality . Question about the structure of code: in 2.0, there's App_code and that article mentions Class Library. Now, if I want to use Class Library, should this go in APP_code? Just need some general ideas about how to structure the 3 tiers.. Quote
Gill Bates Posted September 28, 2006 Posted September 28, 2006 If you have a class library in its own DLL you just add it as a reference to the website and it will be placed in the Bin directory. The App_Code directory is used in the new ASP.NET compilation model. Under this model the website is compiled dynamically. When you change a code file in the App_Code directory the site will automatically get recompiled on the next page load. In .NET 1.1 the website was compiled into a static DLL (you could also do dynamic compilation if you wanted). Under the new model for 2.0 you do not even have a .csproj file, so dynamic compilation is the default. If you want, you can download an add-on from Microsoft that will allow you to have projects under 2.0. Quote
eramgarden Posted September 28, 2006 Author Posted September 28, 2006 hmm...this is NEW project , totally done in 2.0.. your comment makes sense but doesnt answer what i'm trying to convey... I want to know what's a good/recommanded/how-everyone-else- does- it structure for this new project... So..should I have my Business Layer and Data Layer in APP_CODE? Then what about the Presentation Layer? If i have 2 Class Libraries for Business Layer and Data layer..they will go into BIN , even tho this is ASP.Net 2.0? For example, if you have a 3-tier app, how have u structured it...what do u see in the Solution Expolerer when it comes to structure of the code? Quote
Gill Bates Posted September 28, 2006 Posted September 28, 2006 Anything that is modular and has a need to be referenced from multiple projects/websites should be compiled into its own assembly. This will most likely include the classes in your business and data layers. When you reference the assembly from your website Visual Studio will automatically copy it into the Bin folder. The only files you should have in the App_Code directory of the website are code files that are directly part of the website, which will be dynamically compiled. These files are mainly going to interact with the Page and classes in your referenced assemblies. I personally try to avoid having any type of business logic in the App_Code directory mainly because 1) it's not modular and I'll probably need to reference it from somewhere else eventually anyway and 2) it's a lot easier to unit test if it's compiled into a static assembly. Quote
eramgarden Posted September 29, 2006 Author Posted September 29, 2006 Thanks, and I found the link below, the last question is basically explains what you have: http://blogs.msdn.com/swisowaty/archive/2005/12/21/506357.aspx Question: "web project" is where i'm going to have my aspx files..this can be in itself a class library...so have 3 class libraries...one for BL , one for DAL and one the aspx pages itself...correct? Quote
Gill Bates Posted September 29, 2006 Posted September 29, 2006 Well, the .aspx pages do not reside in the DLL. They are just text files that reside in the website hierarchy. If you want, their respective code files can be compiled into the DLL. Quote
eramgarden Posted September 29, 2006 Author Posted September 29, 2006 yeah, that was a stupid question :D Let me ask you this: in 2.0, there's no "web application project" and seems like that's an add-on: http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx 2.0 uses a "web site model"...correct..this is what i see when I did "file/add new website". Then when I right click on the solution and choose "add", i see "new project", "visual basic" and "class library" (and other stuff). I also see "other porject types". In 1.1, under this ,there were "enterprise template projects". This is what the vendor at my last job used to put the "web application " under...that's how they organized it. I dont see that in 2.0. No way to organize the "web site" in 2.0 like that? I know i'm beating this to death but my light bulb is getting brighter :) Quote
Gill Bates Posted September 29, 2006 Posted September 29, 2006 That is what I mentioned earlier. They have changed the model and are trying to encourage developers to rely on dynamic compilation for websites. It has been vastly improved in .NET 2.0. Regardless, a lot of people complained about not having the ability to have a .csproj file for web apps so Microsoft released an add-on for Visual Studio 2005. In Visual Studio 2005 you have a solution for the website. You can add other project types to that solution (class libraries, etc), which will be opened with the website. Quote
eramgarden Posted September 29, 2006 Author Posted September 29, 2006 ooooooooh, now i get it. Thanks. It makes sense until i confuse myself again :D Quote
eramgarden Posted October 2, 2006 Author Posted October 2, 2006 I downloaded the "web application" from the Microsoft site...what I dont see is "Add/New Project/Other Pojects/Enterprise Template Projects" and then "Enterprise Template Project" as one f the options... At my last job, vendor used that template and then under it had the "web application" project....instead of having everything under the root... I know I can add Class Libraries with my DAL and BL code under that..but how can I have all my aspx pages organized..instead of having it under the root folder? (So, have 3 project folders: BL,DAL and UI (aspx pages)? Quote
Gill Bates Posted October 2, 2006 Posted October 2, 2006 You can do that by simply adding a new folder and then moving the .aspx into that folder but, remember, the folder that the .aspx is in will need to be part of the url that the client uses. Quote
eramgarden Posted October 2, 2006 Author Posted October 2, 2006 ah , yes... In the "web application", I see a "My Project". I added a class library to the solution and under the class library, there's another "My project"...When I double click on the one under "web application" it jumps to the root "webappliation1"..it gives me options... This is like "properties".. i right clicked to see if i can delete it but i cant... seems like the "web site" model in 2005 is easier! Quote
eramgarden Posted October 2, 2006 Author Posted October 2, 2006 i guess this is only in VB, found a screen shot here and some info: http://webproject.scottgu.com/VisualBasic/UserControls/Usercontrols.aspx Quote
eramgarden Posted October 3, 2006 Author Posted October 3, 2006 probably beating this one to death but i'm getting close to wrap my head around this :rolleyes: On http://www.asp.net site, I downloaded 3 sample projects they have for free to look at the layers and code examples ... I also downloaded "DotNetNuke". For this one, the code is structured under "Windows Application" templates ..instead of for example, "class library". Seems like it's added, then the "form" code is removed. I saw that at my last job too where "web application" template is used to structure the code... wanted to know why someone might choose "windows application" instead of "class library" for a web application. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.