Reputation: 2741
I want to split web.config and take these settings in a external file.
<customErrors mode="Off" defaultRedirect="~/Home/ErrorPage">
<error statusCode="403" redirect="~/Home/ErrorPage"/>
<error statusCode="404" redirect="~/Home/ErrorPage"/>
</customErrors>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="[email protected]">
<network host="smtp.company.com" port="25" password="" userName=""/>
</smtp>
</mailSettings>
</system.net>
I use
<appSettings file="my.config"/>
to have MY settings outside.
But what about the standard settings?
Upvotes: 7
Views: 4906
Reputation: 40150
Many (though not all) of the sections have a configSource
property, which you can use very similarly to how you use the file
property of the appSettings
section.
<customErrors configSource="MyErrors.config" />
<system.net>
<mailSettings>
<smtp configSource="MySmtp.config" />
</mailSettings>
</system.net>
Upvotes: 9
Reputation: 24515
You can separate out some sections of the file, you can't take everything out into separate files.
You should also consider what you gain by doing this.
Upvotes: 0