更新 web.config 以将 aspnetdb 更改为自己的数据库



我正在开发一个Web应用程序,我必须在其中添加一些授权,所以我有一个数据库ASPNETDB。MDF,我希望我的应用程序使用WATERINFO。来自 SQL 服务器的 MDF。

我已经更新了水信息。MDF 包含所有架构和数据,使用 aspnet_regsql.exe

目前我的 web.config 文件的 silverlight 应用程序是

<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="system.serviceModel">
      <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" allowDefinition="MachineToApplication" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <system.web>
    <httpModules>
      <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </httpModules>
    <compilation debug="true" targetFramework="4.0" />
    <roleManager enabled="true"/>
    <authentication mode="Forms">
      <forms name=".AuthorizationSample_ASPXAUTH" />
    </authentication>
    <profile>
      <properties>
        <add name="FriendlyName"/>
      </properties>
    </profile>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="DomainServiceModule" preCondition="managedHandler"
          type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
  </system.webServer>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
</configuration>

现在将其更改为WATERINFO。MDF 我需要更新配置文件

      <?xml version="1.0"?>
    <configuration>
<connectionStrings>
        <add name="DefaultConnectionString" connectionString="Data Source=COMPLEXSQLEXPRESS;Initial Catalog=waterinfo;Integrated Security=True"
    providerName="System.Data.SqlClient" />
      </connectionStrings>
      <configSections>
        <sectionGroup name="system.serviceModel">
          <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" allowDefinition="MachineToApplication" requirePermission="false" />
        </sectionGroup>
      </configSections>

      <system.web>
        <roleManager enabled="true" defaultProvider="DPISqlRoleProvider">
          <providers>
            <add connectionStringName="DefaultConnectionString" applicationName="DPI" name="DPISqlRoleProvider"
     type="System.Web.Security.SqlRoleProvider"/>
          </providers>
        </roleManager>
        <httpModules>
          <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </httpModules>
        <compilation debug="true" targetFramework="4.0" />

        <authentication mode="Forms">
        </authentication>

        <membership defaultProvider="DPISqlMembershipProvider">
          <providers>
            <add connectionStringName="DefaultConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true"
     requiresQuestionAndAnswer="true" applicationName="DPI" requiresUniqueEmail="true" passwordFormat="Hashed"
     maxInvalidPasswordAttempts="5" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0"
     passwordAttemptWindow="10" passwordStrengthRegularExpression="" name="DPISqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider"/>
          </providers>
        </membership>
        <profile>
          <properties>
            <add name="FriendlyName"/>
          </properties>
        </profile>
      </system.web>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules runAllManagedModulesForAllRequests="true">
          <add name="DomainServiceModule" preCondition="managedHandler"
              type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </modules>
      </system.webServer>
      <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
    </configuration>

我在 web.config 文件中更新了这些更改,但无法将数据库更改为新数据库。

我也知道我可以使用<remove "LocalSqlServer">但现在这对生产目的很好

请建议我应该在我的 web.config 文件中进行哪些更改。

谢谢

您需要将 connectionString 标签放在 configSections 下方。 configSections 必须是第一个,如 msdn 中所述。

我解决了这个问题,有一些连接字符串错误和其他一些分钟更改......我需要这样更新 Web.配置文件

 <?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="system.serviceModel">
      <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" allowDefinition="MachineToApplication" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <connectionStrings>
    <add name="DefaultConnectionString" connectionString="My Connection Details"
providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.web>
    <roleManager enabled="true" defaultProvider="DPISqlRoleProvider">
      <providers>
        <add connectionStringName="DefaultConnectionString" applicationName="DPI" name="DPISqlRoleProvider"
 type="System.Web.Security.SqlRoleProvider"/>
      </providers>
    </roleManager>
    <httpModules>
      <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </httpModules>
    <compilation debug="true" targetFramework="4.0" />

    <authentication mode="Forms">
    </authentication>

    <membership defaultProvider="DPISqlMembershipProvider">
      <providers>
        <add connectionStringName="DefaultConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true"
 requiresQuestionAndAnswer="true" applicationName="DPI" requiresUniqueEmail="true" passwordFormat="Hashed"
 maxInvalidPasswordAttempts="5" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0"
 passwordAttemptWindow="10" passwordStrengthRegularExpression="" name="DPISqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider"/>
      </providers>
    </membership>
    <profile>
      <properties>
        <add name="FriendlyName"/>
      </properties>
    </profile>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="DomainServiceModule" preCondition="managedHandler"
          type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
  </system.webServer>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
</configuration>

相关内容

  • 没有找到相关文章

最新更新