如何配置我的web.config文件也在somee.com中

时间:2014-03-17 11:52:59

标签: asp.net sql-server data-storage

web.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>
    <connectionStrings>
  <add name="ApplicationServices" connectionString="data source=LENOVO\RDX;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString2" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString3" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString4" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString5" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString6" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString7" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString8" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString9" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString10" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString11" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString12" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString13" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <add name="DataStorageConnectionString14" connectionString="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"
   providerName="System.Data.SqlClient" />
 </connectionStrings>
  <appSettings>
    <add key="conn" value="Data Source=LENOVO\RDX;Initial Catalog=DataStorage;Integrated Security=True"/>    
  </appSettings>
    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
        <authentication mode="Forms">
            <forms loginUrl="~/Pages/Home.aspx" timeout="2880" defaultUrl="~/Pages/Home.aspx"/>
        </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"/>
    <defaultDocument>
      <files>
        <clear />
        <add value="Default.aspx" />
      </files>
    </defaultDocument>
  </system.webServer>
</configuration>

网站给了我这些连接字符串

workstation id=DataStorage.mssql.somee.com;packet size=4096;user id=davidsweetboy_SQLLogin_1;pwd=mypassword;data source=DataStorage.mssql.somee.com;persist security info=False;initial catalog=DataStorage

并且我对此非常陌生,我对此没有太多了解,任何人都可以建议我如何编辑web.config文件将我的asp.net web应用程序连接到sql server数据库。

2 个答案:

答案 0 :(得分:1)

将以下连接字符串放在ASP.NET MVC APPLICATION中的web.config文件中。 的语法

  <add name="<Your Context Object>"
    connectionString="metadata=<Path-to-your-CSDL>.csdl|<Path-to-your-SSDL>.ssdl|<Path-to-your-MSL>.msl;
                      provider=System.Data.SqlClient;
                      provider connection string='workstation id=<Provided by Somee>;packet size=<Provided by Somee>;user id=<Provided by Somee>;pwd=<Provided by Somee>;data source=<Provided by Somee>;persist security info=False;initial catalog=<Your database name>'"
    providerName="System.Data.EntityClient" />

示例

<add name="TestContext" connectionString="metadata=res://*/TestContext.csdl|res://*/TestContext.ssdl|res://*/TestContextContext.ms; provider=System.Data.SqlClient; provider connection string='workstation id=Test.mssql.somee.com;packet size=4096;user id=TestUser_SQLLogin_1;pwd=abcd1234xy;data source=Test.mssql.somee.com;persist security info=False;initial catalog=Test'" providerName="System.Data.EntityClient" />

我希望这个答案可能对在Somee.com上免费部署应用程序的人有所帮助

感谢。

答案 1 :(得分:0)

首先,我强烈建议不要在公共论坛中粘贴实际的用户名/密码:) 其次,您拥有的连接字符串是由';'分隔的值列表。它们应该插入“DataStorageConnectionString”的“connectionstring =”值,最好是在最后。

由于某种原因,您已多次克隆连接字符串,请务必删除未使用的连接字符串。