How to separate the three tiers / layers without using MVC Template? RRS feed

  • Question

  • Using - Visual Studio 2010, Targetting - .NET Framework 4.0, Application Type - Web Application

    Problem -

    I want to crete a simple ASP.NET application which can be designed like normal ASP.NET application. But I want to separate the tiers - Presentation, Business Logic, Service Layer, Database Layer.

    I dont want to use the MVC template in VS 2010.

    The Database layer will contain the ORM(edmx file)
    THe Business Layer will contain the classes representing business objects.
    THe Service Layer will contain WCF services and contracts.
    The WEb Application will contain ASP.NET pages. The web pages' code behind file(.cs) will contain the calls to the Business or Service Layer which in turn may call the database Layer. I have two architectures in mind :-

    1.) Create a Solution with 4 Projects

        ├───WebApplication - Presentation Layer(ASP.NET)
        ├───ClassLibrary   - Service Layer(DLL)
        ├───ClassLibrary   - Business Logic Layer(DLL)
        └───ClassLibrary   - Database Layer(DLL)

    2.) Using Solution Folders (Someone suggested me this way). But i am unclear how to do this.

    Please suggest an apropriate architecture, out of these two or any other which would efficiently separate the layers.

    Vibhor Agarwal
    • Edited by Vibhor Agarwal Sunday, August 21, 2011 5:01 PM spelling mistake
    Sunday, August 21, 2011 4:59 PM

All replies

  • You wanted to use WCF services as service layer. And I believe that you are envisioning  UI makes call to WCF services for transactions. I would group the code in the following structure:

    ---Solution1 with two projects:

    a) Webapplication - Presentation layer (ASP.Net)

    b) Classlibrary - DataAccesssAgent (Proxy for calling services or external systems)

    ---Solution2 with 3 projects:

    a) Class library - Service layer (WCF)

    b) Class library - Business logic layer

    c) Classlibrary - Database layer

    Note: I would think of having utilities (helper classes and code) as one more project in above each solution as applicable

    When we define multi tier architecture we need to group the code base files as projects and solutions keeping in mind of deployment. The above two solutions can be deployed in more than one boxes independently.

    Hope this helps!!!







    Tuesday, August 23, 2011 8:40 AM
  • this is what i created in the beginning

        ├───WebApplication - Presentation Layer(ASP.NET)
        ├───ClassLibrary   - Service Layer(DLL)
        ├───ClassLibrary   - Business Logic Layer(DLL)
        └───ClassLibrary   - Database Layer(DLL)

    But later i chaged it to (this is the current heirarchy)

        ├───WebApplication - Presentation Layer(ASP.NET)
        ├───ClassLibrary   - Business Layer (Services +  Business Logic)(DLL)
        └───ClassLibrary   - Database Layer(DLL)

    I thought of deploying the projects on the different machines. I am developing all these apps currently at the same machine

    but there is a problem - ORM (edmx file) is there in the database layer and its connection string is in the app.config file.

    When i make a call from WebApp to database through services i cant connect to the database bcoz the connection string is not available.

    But after reding ur post it seems pretty obvous to separate the solutions keeping in mind the deployment. If i am not getting it wrong u r saying that we can deploy these two solutions on different machines where the first solution talks with the second through the proxy object of the service. In that case i think it would be better to develop using "Solution Folders". There will be two solution folders each containing a solution.

    Vibhor Agarwal
    Tuesday, August 23, 2011 7:28 PM