views:

106

answers:

2

Hi,

I have the same problem as a previously solved question however, this solution did not help me.

I have posted the previous question and answer below:

http://stackoverflow.com/questions/2215963/forms-authentication-works-on-dev-server-but-not-production-server-same-sql-db/2963985#2963985

Question:

I've never had this problem before, I'm at a total loss.

I have a SQL Server 2008 database with ASP.NET Forms Authentication, profiles and roles created and is functional on the development workstation. I can login using the created users without problem.

I back up the database on the development computer and restore it on the production server. I xcopy the DLLs and ASP.NET files to the server. I make the necessary changes in the web.config, changing the SQL connection strings to point to the production server database and upload it.

I've made sure to generate a machine key and it is the same on both the development web.config and the production web.config.

And yet, when I try to login on the production server, the same user that I'm able to login successfully with on the development computer, fails on the production server.

There is other content in the database, the schema generated by FluentNHibernate. This content is able to be queried successfully on both development and production servers.

This is mind boggling, I believe I've verified everything, but obviously it is still not working and I must have missed something. Please, any ideas?

Answer:

I ran into a problem with similar symptoms at one point by forgetting to set the >applicationName attribute in the web.config under the membership providers element.

Users are associated to a specific application. Since I didn't set the applicationName, >it defaulted to the application path (something like "/MyApplication"). When it was moved >to production, the path changed (for example to "/WebSiteFolder/SomeSubFolder /MyApplication"), so the application name defaulted to the new production path and an >association could not be made to the original user accounts that were set up in >development.

Could your issues possibly be the same as mine?

I have this already in my web.config but still get the issue. Any ideas?

<membership defaultProvider="AspNetSqlMembershipProvider">
            <providers>
                <clear/>
                <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/"/>
            </providers>
        </membership>
        <profile>
            <providers>
                <clear/>
                <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" applicationName="/"/>
            </providers>
        </profile>
        <roleManager enabled="false">
            <providers>
                <clear/>
                <add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
                <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            </providers>
        </roleManager>

Any help is greatly appriciated.

A: 

your current line is

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

but shouldn't it be

<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/"/>
Joakim
sorry about the typo that was simply a wiki formatting error. :( i have ammended it
Desmond
Does anyone have any other ideas?
Desmond
If you can query the database fine from the application but not being able to log in then do a try catch and find out what kind of sqlexception that is being raised when you try to login, should clarify what the issue might be. otherwise go through the call stack from the point where you try to login and you should get an idea of what might cause it. I myself use a custom formsauthentication since I usually don't need most of the tables.this works for both winforms and mvchttp://stackoverflow.com/questions/2771094/asp-net-mvc2-custom-membership/2925372#2925372
Joakim
+1  A: 

1) Try adding a defaultProvider setting:

<membership defaultProvider="AspNetSqlMembershipProvider">
      <providers>

2) You have

applicationName="/"/

Look in the application table, what is the name used?

3)

<add name="AspNetSqlMembershipProvider"> 

shouldn't have a close bracket after "AspNetSqlMembershipProvider"

Joe R
/ is the name used in the membership table and I added the default provider but it still doesnt login.
Desmond