English 中文(简体)
服务器 网络替换
原标题:Server specific Web.config replacement

I am currently using Visual Studio 2010. I want to set up a different connection string for my "Testing" Configuration. I have tried doing it by using config transformations, but it does not seem to work.

在我的<星座>Web.config上,我的联系人如下:

<add name="MyDb" connectionString="Data Source=.SQLEXPRESS;Initial Catalog=DevelopmentDb;Integrated Security=SSPI; MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />

我发现,你可以取代网络界定的连接线,添加“组合转变”。 我在网上被点击,并点击“Add config transformations”。 这创造了一个<><>>>>。 Web.TEST.config file. 然后,我又增加了一条连接线,但似乎正在发挥作用。 它仍在使用Web.config界定的连接线。

http://strong。 Web.TEST.config:

<?xml version="1.0"?>

<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <!--
    In the example below, the "SetAttributes" transform will change the value of 
    "connectionString" to use "ReleaseSQLServer" only when the "Match" locator 
    finds an atrribute "name" that has a value of "MyDB".
  -->

    <connectionStrings>
      <add name="MyDb" 
        connectionString="Data Source=.SQLEXPRESS;Initial Catalog=TestDb;Integrated Security=SSPI; MultipleActiveResultSets=True" 
        xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
    </connectionStrings>
  <system.web>
    <!--
      In the example below, the "Replace" transform will replace the entire 
      <customErrors> section of your web.config file.
      Note that because there is only one customErrors section under the 
      <system.web> node, there is no need to use the "xdt:Locator" attribute.

      <customErrors defaultRedirect="GenericError.htm"
        mode="RemoteOnly" xdt:Transform="Replace">
        <error statusCode="500" redirect="InternalError.htm"/>
      </customErrors>
    -->
  </system.web>
</configuration>

对我可能失踪的任何想法?

问题回答

页: 1 该项目不是在您汇编时。

如果你使用国际电子数据系统,你可以部署到组合的网络应用程序目录,这将导致这一转变的应用。





相关问题
ASP.NET MVC Web Config Email Settings

I m trying to include some SMTP settings in my ASP.NET MVC project by adding the following to my Web.Config file: <system.net> <mailSettings> <smtp> <network ...

change web.config settings in code behind

i m using a third party upload control and there r few settings in web.config <uploadSettings allowedFileExtensions=".pdf,.xls,.doc,.zip,.rar,.jpg" scriptPath="upload_scripts" imagePath="" cssPath=...

WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

热门标签