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?
Yes you can have two web. config files in application. There are situations where your application is divided in to modules and for every module you need separate configuration. For example if you have a application which has two modules lets say accounts and sales.
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.
More info at MSDN
<customErrors configSource="MyErrors.config" />
<system.net>
<mailSettings>
<smtp configSource="MySmtp.config" />
</mailSettings>
</system.net>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With