1

I am a newbie in ASP.net and just following Tutorials. This Particular Problem has been Giving me a Real Headache, I have developed a website in VS 2010 , used the ASPNETDB SQL server database provided by Asp.Net Login Controls for creating users and roles. Also added Some tables, After i Was Done Used the " publish to Provider " feature to generate the Script (ASPNETDB.MDF.sql) . I Used this Script to Generate the Database and Tables -Sql Server 2008 R2 management Studio, and Modified the web.config Like This-

<!--Connection String-->
                <connectionStrings>
        <remove name="LocalSqlServer" />
        <add name="LocalSqlServer"  connectionString="Server=AkumJamir-PC\SQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=true" providerName="System.Data.SqlClient" />
                <add name="con" connectionString="Server=AkumJamir-PC\SQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=True"/>
                <add name="ConnectionString" connectionString="Server=AkumJamir-PC\SQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<roleManager enabled="true">
        <providers>
            <remove name="AspNetSqlRoleProvider"/>
            <add connectionStringName="ConnectionString" applicationName="/"
                 name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider,System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            <remove name="AspNetWindowsTokenProvider"/>
        </providers>
    </roleManager>

<membership>
        <providers>
            <remove name="AspNetMembershipProvider"/>
            <add connectionStringName="ConnectionString" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphaNumericCharacters="1" passwordAttemptWindow="5" passwordStrengthRegularExpression="" name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider,System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </providers>
    </membership>   
    <webParts>
        <personalization defaultProvider="AspNetSqlPersonalizationProvider">
            <providers>
                <remove name="AspNetSqlPersonalizationProvider"/>
                <add name="AspNetSqlPersonalizationProvider" type="System.Web.UI.WebControls.Webparts.SqlPersonalizationProvider"
                 connectionStringname="ConnectionString" applicationName="/"/>
            </providers>
        </personalization>
    </webParts>

Now The Problem is That Works On my Development Machine But on our Staging Server, It Doesnt connect to the Database whenever i try browse to Some Pages where i have some data to be displayed from the Database Neither Does the Login Page Work.The connectionString Looks Like This in the Server:

<!--Connection String-->
                <connectionStrings>
        <remove name="LocalSqlServer" />
        <add name="LocalSqlServer"  connectionString="Driver={SQL Native Client};Server=WIN-K16NMM4128C;Initial Catalog=ASPNETDB;Integrated Security=true" providerName="System.Data.SqlClient" />
                <add name="con" connectionString="Server=WIN-K16NMM4128C;Initial Catalog=ASPNETDB;Integrated Security=True"/>
                <add name="ConnectionString" connectionString="Data Source=WIN-K16NMM4128C\SqlServer2008;Initial Catalog=ASPNETDB;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>

I Am Eating My braings Away, I've Gone through the Topics Covered Already,,,, Thanks For any Advise...

AkumJamir
  • 25
  • 1
  • 7

2 Answers2

2

I was facing the same issue. I've just enabled ASP/Authentication in IIS manager and I've set Basic Authentication=true. It is working now.

herchaka
  • 21
  • 2
1

You are using integrated security in your connection strings. Configure it to use sql authentication. Something like this:

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Paul Fleming
  • 24,238
  • 8
  • 76
  • 113
  • Thanks a Lot...>Will Try Tat tomorrow.....Oh and Data Source=WIN-K16NMM4128C\SqlServer2008 is Actually Data Source=WIN-K16NMM4128C... Was trying Whatever Came Across.Will Update on This issue.Bt anyway..Thnx @ flem – AkumJamir Jul 18 '12 at 15:26
  • Hmmmm just Wondering ..... If I Set `IntegratedSecurity=true` I Dont Need To use The UserName and Password Rite? Then Wat Can Be The Reason why the Connection Fails?? is It Mandatory To set the UserName and Password? Thanks – AkumJamir Jul 18 '12 at 15:45
  • Integrated security more or less means pass through the current user (i.e windows integration). It is trying to connect to your database server (and database) as the user that is running the application. Locally, this works fine because you are logged into you pc and you are owner of your local database. This is unlikely to be the case on the server. – Paul Fleming Jul 18 '12 at 15:46
  • Well Sorry For Being Stupid....... But i have second thoughts about putting the Uname and password there.....Any ideas on How to Encrypt the connection in that Case??? Any alternatives??? Thnx Again – AkumJamir Jul 18 '12 at 16:11
  • Hi!!! Got my Connection working by Passing the userid and password `Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;` Now the Sad Part is The Login Page does Not Work,.... – AkumJamir Jul 19 '12 at 09:41
  • Maybe raise a new question for that if you're struggling to resolve the issue? – Paul Fleming Jul 19 '12 at 10:41