2

I'm trying to host my first ASP.NET project, after the initial upload via FTP I got SQL connection Errors, so after doing some searching I figured it was my Connection String, so I fixed it by properly putting my hosts info:

 <add name="orangefreshConnectionString1" connectionString="Data Source=<server>;Initial Catalog=<catalog>;User Id=<user>;Password=<pwd>;" providerName="System.Data.SqlClient" />

So this fixed my problem, my Website is up now... except for when I try to login, I get another SQL connection error.

I use 2 databases on my website: dbstart and ASPNETDB (last one for membership)

ASPNETDB is handled on my development web.config as: providers>

      <clear />
      <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
  </providers>

I know there is something that needs to be changed here, but my google queries have not been helpful so far in finding an answer...

Here is my development web.config content:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <add name="orangefreshConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\orangefresh.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
    <add name="orangefreshEntities" connectionString="metadata=res://*/App_Code.Orangefresh.csdl|res://*/App_Code.Orangefresh.ssdl|res://*/App_Code.Orangefresh.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\orangefresh.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <system.web>
    <customErrors mode="Off"/>
      <membership>
          <providers>
              <clear />
              <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
          </providers>
      </membership>
    <roleManager enabled="true" />
      <authentication mode="Forms">
          <forms loginUrl="default.aspx"></forms>
      </authentication>
    <pages theme="orangefresh" />
    <compilation debug="false" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
      </assemblies>
      <buildProviders>
        <add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
      </buildProviders>
    </compilation>
    <httpRuntime requestValidationMode="2.0" />
  </system.web>
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network" from="João &lt;email@email.com&gt;">
        <network host="host" userName="user" password="pass" />
      </smtp>
    </mailSettings>
  </system.net>
    <location path="Management">
        <system.web>
            <authorization>
                <allow roles="Admin"/>
                <deny users="*"/>
            </authorization>
        </system.web>
    </location>
</configuration>

How can I properly refer to my membership database on web.config?

kprobst
  • 16,165
  • 5
  • 32
  • 53
Jorg Ancrath
  • 1,447
  • 10
  • 34
  • 61
  • Did you run ASPregSQL.exe to prep the Membership? That is not the exact name but it will be in – paparazzo Aug 20 '12 at 18:50
  • I just found that exe and loaded up membership on my database, is there any way to import the settings I created on ASPDBNET to the database that i just added membersip? Like, I already had set up an Admin account and whatnot – Jorg Ancrath Aug 20 '12 at 18:58

2 Answers2

3

Change inside of this:

<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>

the

connectionStringName="LocalSqlServer"

to

connectionStringName="orangefreshConnectionString1" 

or

connectionStringName="orangefreshEntities"

I can't tell which connection you use for what, but that is what needs changed.

TheGeekYouNeed
  • 7,509
  • 2
  • 26
  • 43
  • This is after running aspnet_regsql right? I didn't know about it by the time I created this. So I ran this tool on my original database, I'm just wondering now if there is way to import all my ASPDBNET settings into this? Like for example, the accounts I created while developing my website – Jorg Ancrath Aug 20 '12 at 19:01
0

Yes you backup the original SQL database then restore over the top. But you can't just start with restore. You need to prep with the tool. On the SQL restore you need to check a replace option. Also in security on the database you may need to drop and re add the users and the user may have the same name but likely not the same internal id.

paparazzo
  • 44,497
  • 23
  • 105
  • 176