Using different Web.config in development and production environment

前端 未结 10 2070
梦如初夏
梦如初夏 2020-11-22 12:50

I need to use different database connection string and SMTP server address in my ASP.NET application depending on it is run in development or production environment.

<
10条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 13:32

    The tag in web.config supports a file attribute that will load an external config with it's own set of key/values. These will override any settings you have in your web.config or add to them.

    We take advantage of this by modifying our web.config at install time with a file attribute that matches the environment the site is being installed to. We do this with a switch on our installer.

    eg;

    
    
    
    
    
    

    Note:

    • Changes to the .config specified by the attribute won't trigger a restart of the asp.net worker process

提交回复
热议问题