none
Merge 2 Config RRS feed

  • Question

  • Hi,

    I have 1 Solution which has 2 different projects: 1. ASP.NET MVC  and 2. WCF Application.

    Right now each project has different config.

    However, they are a lot of similiarity on both config, for example: they are using the same connectionstring, the same mail setting, etc.

    Thatsway the idea is that I want to merge this both similiarity into only 1 config. So whenever I need to do any change I only need to touch 1 config.

    Is there any solution, that help me to merge all similiarity settings from both config into only 1 config? however each projects should still have its own config for its own specific settings.

    Many thanks for your help :)

    Tuesday, October 21, 2014 2:30 PM

Answers

  • No, the MVC solution needs its own config file a Web config. And the WCF service needs its own own Web config file. The two config files maybe similiar in a lot of ways, but each solution needs its own Web config, resulting into two config files.

    If you have a repository like TFS or others, then you can sahre the Web.config between the projects making it look to the repository like there is only one config, but when the projects are deployed, there are still going to be a single Web.config for each solution that are not sharable between the two running solutions. The MVC soution can't go access the Web.config that is being used by the WCF solution.

    What would be sharable but still indepented used by both solitions would be the the Service Layer project as explained. 

    Thursday, October 23, 2014 1:24 PM

All replies

  • Is there any solution, that help me to merge all similiarity settings from both config into only 1 config? however each projects should still have its own config for its own specific settings

    .NET is only looking at the app.configs at the project level in debug mode in Visual Studio.

    .NET at runtime looks in the root.config for any settings that may be need by subordinate projects referenced by the root project.

    Lets say you have a Windows desktop exe project, you have a classlib project called a DAL that the Windows Desktop exe project is referenceing for data access with a database. The connection string for the DAL is going to be in the app.config of the DAL project. But that connection string must be copied to the app.config of the root project, which is the root.config for the entier solution. .NET looks in the root-config at runtime for any configuration information.

    The same things apply to the root Web.config for Web application, even if it is referencing non Web projects that have thier own app.config information. The config information in the subordinate app.configs must be copied to the root Web.config.

    What is the project architecture or project hierarchy for your solution? 

    Tuesday, October 21, 2014 3:51 PM
  • Hi,

    Thanks for the explanation. The architecture for my project like this

    architecture

    Another said we have 2 different separate application (WCF and ASP.NET MVC) using the same Core functionality. Thatsway they both have their own config. However because they shared also some similiarity in config, I want to merge this all these similiarity into 1 config. So whenever I need to change I only need to change to 1 place. Any Idea?

    Thanks

     


    • Edited by wapt49 Thursday, October 23, 2014 8:09 AM
    Thursday, October 23, 2014 8:07 AM
  • How is it that an ASP.NET MVC UI application is a client to some other application and the ASP.NET MVC solution  is a client to it?  What is this client where both an ASP.NET MVC solution and WCF solution are  clients to it in the same .NET solution as shown in the diagram?  
    Thursday, October 23, 2014 9:48 AM
  • Hi,

    I mean for client here could be browser, could be sharepoint application that consume WCF Service or could be anything. Please let me know if you need another information

    Regards

    Thursday, October 23, 2014 10:06 AM
  • I mean for client here could be browser, could be sharepoint application that consume WCF Service or could be anything. Please let me know if you need another information

    Then no, you cannot have one config file. The configuration information is not sharable between the ASP.NET MVC solution and the WCF service, with the WCF service I assume is a WCF Web service. They are two independent solutions. They may be in the same .NET solution file, but each are their own independent solution.

    I'll put it to you point-blank. Your architecture is not solid here. It should be one of two things.

    Service layer project that consumes WCF service

    BLL -- consumed by the Service Layer

    WCF service consumed by the BLL

    DAL consumed by the BLL

    EF or the Model

    OR

    Service Layer that consumes the BLL

    BLL

    BLL that consumes the WCF service

    WCF

    WCF service that consumes the DAL

    DAL

    DAL that uses the EF model

    By using the Service Layer project, the ASP.NET MVC solution without the EF stuff can be removed totally from the MVC solution, because the Service layer is the middle-man with the client MVC UI and the Service Layer is the one working with the back-end.

    A sharepoint client could use the Service Layer as well in the same manner as the Service Layer is the middle-man  that is accessing the back-end.

    The Service Layer and what is behind the service layer (the middle-man) can be consumed by any type of client. The client doesn't care, because the Service Layer is acting on its behalf. The client can be a Windows desktop, WPF, Console Application, Windows Service, another WCF service soltion, because the middle-man the Service layer is acting on the behalf of the client.

    That's the piece you are missing here is the Service layer classlib project that everything sits behind -- the middle-man.

    Thursday, October 23, 2014 11:18 AM
  • Hi,

    Yes you are right.. They are both independent solution. Maybe I just make you confused by put the client in my architecture. You can just ignore the client, because actually client is outside the solution :)

    And then about the architecture actually BLL is consumed by WCF Service and ASP.NET MVC. BLL has all CRUD operationen.  So if WCF Service or ASP.NET MVC want to make CRUD Operationen, this happens through BLL.

    And about config, you said

    "Then no, you cannot have one config file. The configuration information is not sharable between the ASP.NET MVC solution and the WCF service, with the WCF service I assume is a WCF Web service. They are two independent solutions. They may be in the same .NET solution file, but each are their own independent solution."

    It is still not possible even my WCF Service Hosted in IIS? 

    Regards

    Thursday, October 23, 2014 11:49 AM
  • No, the MVC solution needs its own config file a Web config. And the WCF service needs its own own Web config file. The two config files maybe similiar in a lot of ways, but each solution needs its own Web config, resulting into two config files.

    If you have a repository like TFS or others, then you can sahre the Web.config between the projects making it look to the repository like there is only one config, but when the projects are deployed, there are still going to be a single Web.config for each solution that are not sharable between the two running solutions. The MVC soution can't go access the Web.config that is being used by the WCF solution.

    What would be sharable but still indepented used by both solitions would be the the Service Layer project as explained. 

    Thursday, October 23, 2014 1:24 PM