SORU
27 NİSAN 2011, ÇARŞAMBA


Web.Config Debug/Release

Web biliyorum.Visual Studio 2010 config hata Ayıklama modundan veritabanlarından Release moduna geçiş olanağı sağlar.

İşte benim Web sitesi.Bırakın.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">

  <connectionStrings>
    <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
      providerName="System.Data.SqlClient" />
    <add name="Testing1" connectionString="Data Source=test;Initial Catalog=TestDatabase;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
  </system.web>

</configuration>

İşte benim Web sitesi.Hata ayıklama.kod 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">

  <connectionStrings>
    <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
      providerName="System.Data.SqlClient" />
    <add name="Live1" connectionString="Data Source=Live;Initial Catalog=LiveDatabase;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
  </system.web>

</configuration>

Ve bu benim isimdir.kod config:

<?xml version="1.0"?>

<!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 -->
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />

    <authentication mode="Forms">
       <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>

    <membership>
       <providers>
          <clear/>
          <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
         enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
         maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
         applicationName="/" />
       </providers>
    </membership>

    <profile>
       <providers>
          <clear/>
          <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
       </providers>
    </profile>

    <roleManager enabled="false">
       <providers>
          <clear/>
          <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
    <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
       </providers>
    </roleManager>

  </system.web>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

Ben projemi yayınlamak zaman hiçbir şey benim Web içinde gösteriliyor.yapılandırma dosyası.Canlı Veritabanı bağlantısı benim dize gösteren değil mi?

CEVAP
27 NİSAN 2011, ÇARŞAMBA


Web.config Visual Studio 2010 kullanın "" geçerli web.dönüştürmek için XSLT parçası dönüşümleri onun içine dosya config .Hata ayıklama ya .Sürüm Sürüm.

Senin içinde ./Debug.Sürüm dosyaları, bağlantı dizesi alanları aşağıdaki parametreyi ekleyin:

xdt:Transform="SetAttributes" xdt:Locator="Match(name)"

Bu bağlantı dizesi her satırı bir isim Bul ve özelliklerine göre güncelleme neden olur.

Not: değişmedikleri içinde providerName eğer parametre dosyalarını dönüştürmek güncelleme hakkında endişelenmenize gerek olmayacak.

İşte benim apps biri bir örnek. İşte web.dosya bölümünde config:

<connectionStrings>
      <add name="EAF" connectionString="Data Source=NTSQLT\S2K5TST;Initial Catalog=HR;User ID=EAFApp;Password=XXXX" providerName="System.Data.SqlClient" />
</connectionString>

Ve burada web.config.yayın bölümüne uygun bir dönüşüm yapıyor:

<connectionStrings>
      <add name="EAF" connectionString="Data Source=NTSQLP\S2K5TST;Initial Catalog=HR;User ID=EAFApp;Password=YYYY" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
</connectionStrings>

Bir ilave not: sadece site yayınlama, sadece çalıştırmak ne zaman ortaya F5 veya CTRL F5 ile Dönüştürüyor. Eğer belirli bir config karşı bir güncelleştirme yerel olarak çalıştırmak istiyorsanız, el ile Web değiştirmek zorunda kalacak.bunun için yapılandırma dosyası.

Daha fazla bilgi için MSDN belgelerine bakın

https://msdn.microsoft.com/en-us/library/dd465326(VS.100).aspx

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Grace Su

    Grace Su

    6 Ocak 2006
  • Major FX

    Major FX

    6 HAZİRAN 2012
  • Mindy

    Mindy

    20 NİSAN 2006