Is it possible to transfer the web.config file across several projects in a solution? (ASP.NET)

I have a solution consisting of a web application and several projects, is it possible to share the configuration in the web application throughout the solution?

thank

+5
source share
3 answers

It seems that this is possible, you can try the following:

web.config . ( ) ( Add Existing Item ). - -. Add Existing Item -, web.config Add As Link. - .

alt text

, , web.config , web.config .

+8

, . web.config -. web.config, , ASP.NET .

+5

Web.config web.config. , web.config IIS machine.config web.config .NET(C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG ).

A better example would be to use the LocalSqlServer connection string. It is defined in machine.config as

<connectionStrings>
    <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;  
    Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;
    User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>

If, for example, you use the Login control and debug and request connection strings, then this will also be included.

So, if you need some settings common to several applications, put them in a web.config file, which is high enough in the hierarchy, ultimately in the machine.config file.

0
source

All Articles