Sunday, February 26, 2012

Error with asp admin/logins on live server

I have created a site using VWDExpress and now that I've finished testing have moved it over to the server which runs SQLServer 2000. Part of the site requires login, so I created the membership using the ASP.net web configuration tool and when testing locally worked well.

Now though that I've copied the web site over, when I try to log in I get the error:

System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified

Obviously its some sort of configuration issue, but I don't know what.

What do I have to change to make this work from a test machine to a live server?


Thanks

Have you configured your machine.config and web.config on the live server (where you have SQL Server 2000) to work with SQL Server 2000 because by default it looks for SQL Server 2005?

bullpit

|||

bullpit:

Have you configured your machine.config and web.config on the live server (where you have SQL Server 2000) to work with SQL Server 2000 because by default it looks for SQL Server 2005?

bullpit

I ran through the steps listed here http://msdn2.microsoft.com/en-us/library/aa479307.aspx but it gets to a point and says"The easiest way to have your application take advantage or your newly created database is just to replace he connection string value of this localSQLServer setting in your apps web.config". The problem i have is that i dont know what or how to modify?

Now though Im getting the errorSystem.ArgumentException: Invalid value for key 'attachdbfilename' when i try to access the database even though it appears to point to a valid DB file (i.e.

data source=SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true)

thanks for any assistance

|||

Ok...Lets start from the beginning. What my understanding is that your dev server had SQL Server Express edition and your live server has SQL Server 2000. Now, if you have not changed any configuration settings in config files, heres what you have to do. Make sure you have ASPNETDB in SQL Server 2000. If not, locate aspnet_regsql.exe in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 and run it.

Now: Locate machine.config.

If Windows Server 2000 is your live server, then it will be located in C:\WINNT\Microsoft.NET\Framework\v2.0.50727\CONFIG

Modify <connectionStrings> tag like this. I commented the default string just in case it gets messed up. Also, make a copy of machine.config before altering it.

<connectionStrings><!-- <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>--><add name="LocalSqlServer" connectionString="YOUR CONNECTION STRING TO SQL SERVER 2000 ASPNETDB"/> </connectionStrings> Then: add this connectionString in your application web.config file:<add name="LocalSqlServer" connectionString="YOUR CONNECTION STRING TO SQL SERVER 2000 ASPNETDB"/>Add the following tags just before your </system.web> tag<membership> <providers><remove name="AspNetSqlMembershipProvider"/> <add name="AspNetSqlMembershipProvider"type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"connectionStringName="LocalSqlServer"enablePasswordRetrieval="false"enablePasswordReset="true"requiresQuestionAndAnswer="true"applicationName="/YOUR APPLICATION NAME" MAKE SURE TO CHANGE THE NAME TO YOUR APPLICATION NAMErequiresUniqueEmail="false"passwordFormat="Hashed"maxInvalidPasswordAttempts="5"minRequiredPasswordLength="7"minRequiredNonalphanumericCharacters="1"passwordAttemptWindow="10"passwordStrengthRegularExpression="" /> </providers></membership> <profile><providers> <add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/"type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers></profile>

Try this and let me know if you are getting anywhere.

Good luck...

bullpit

|||

bullpit:

Make sure you have ASPNETDB in SQL Server 2000. If not, locate aspnet_regsql.exe in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 and run it.

Seems as though im falling at the first hurdle then! The database isn't in SQLServer at all, because it was created using the ASP web admin tool and resides in the \app_data\ folder of my site. I have copied this to the server but obviously SQLServer doesn't pick it up. If i run the aspnet_regsql tool then its not in the drop-down list of databases to intialise.

Im not sure how to proceed now to get it in SQLServer 2000.

Thanks for all the help btw.

|||

Lets try this:

Just go thru all the default steps of the wizard, leave the value as <default> in dropdown and click next, verify in the last step that the wizard is creating ASPNETDB. click finish. see if this helps.

good luck...

bullpit

|||

bullpit:

Lets try this:

Just go thru all the default steps of the wizard, leave the value as <default> in dropdown and click next, verify in the last step that the wizard is creating ASPNETDB. click finish. see if this helps.

good luck...

bullpit

It Did, Thanks!I now have a blank aspnetdb showing in SQLServer 2000 and another (populated with users and passwords) in the \app_data folder.

How do i go aobut moving from one to the other?

|||

elDeeJay:

bullpit:

Lets try this:

Just go thru all the default steps of the wizard, leave the value as <default> in dropdown and click next, verify in the last step that the wizard is creating ASPNETDB. click finish. see if this helps.

good luck...

bullpit

It Did, Thanks!I now have a blank aspnetdb showing in SQLServer 2000 and another (populated with users and passwords) in the \app_data folder.

How do i go aobut moving from one to the other?

I should have said,

How do i go about moving from one to the other and getting the membership pages created with the ASP web based management tool to recognise this new database location??

Thanks again

|||

You have to configure web.config and machine.config for that. I have already explained that earlier.

bullpit

|||

bullpit:

You have to configure web.config and machine.config for that. I have already explained that earlier.

bullpit

OK, so I deployed my database using this guide (http://weblogs.asp.net/scottgu/archive/2006/12/22/recipe-deploying-a-sql-database-to-a-remote-hosting-environment-part-1.aspx) and now the SQLServer 'sees' the database. I updated my web.config to point to the database on the server and now the login page loads. However, when i go to login, its telling me the login is rejected, for ALL the users, even though i know the login details are correct.

Also, if the data is in the SQLServer database, but the details are encrypted, how do i go about adding new users etc?

I can't belive the process is this coplex. I would have thought it would know the database is in the \app_data\ folder and copying this over would have been sufficient, whatever host it was running on! :(

|||

Well...copying is not the same is copy-paste operation in Windows plateforms. You have to detach the database and then attach it to the new DBMS. Can you paste your web.config please so that I can see what setting you have?

bullpit

|||Certainly (and i really appreciate the time you are giving up to help btw)

123<!--45 Note: As an alternative to hand editing this file you can use the67 web admin tool to configure settings for your application. Use89 the Website->Asp.Net Configuration option in Visual Studio.1011 A full list of settings and comments can be found in1213 machine.config.comments usually located in1415 \Windows\Microsoft.Net\Framework\v2.x\Config1617-->1819<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">2021 <appSettings/>2223 <connectionStrings>2425 <remove name="LocalSqlServer" />2627 <add name="ENQConnectionString" connectionString="Data Source=WEBSERVER;Initial Catalog=ENQUIRIES;Integrated Security=True" providerName="System.Data.SqlClient" />2829 <add name="LocalSqlServer" connectionString="Data Source=WEBSERVER;Initial Catalog=aspnetdb;Integrated Security=True" providerName="System.Data.SqlClient" />3031 </connectionStrings>3233 <system.web>3435 <globalization culture="en-GB" uiCulture="en-GB" />3637 <roleManager enabled="true" />3839 <authentication mode="Forms" />4041 <pages styleSheetTheme="DataWebControls"/>4243<!--4445 Set compilation debug="true" to insert debugging4647 symbols into the compiled page. Because this4849 affects performance, set this value to true only5051 during development.5253 -->5455 <compilation debug="true" defaultLanguage="c#">5657 <assemblies>5859 <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />6061 <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />6263 <add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />6465 </assemblies>6667 </compilation>6869 <customErrors mode="Off"/>7071<!--7273 The <authentication> section enables configuration7475 of the security authentication mode used by7677 ASP.NET to identify an incoming user.7879 -->8081 <!--8283 The <customErrors> section enables configuration8485 of what to do if/when an unhandled error occurs8687 during the execution of a request. Specifically,8889 it enables developers to configure html error pages9091 to be displayed in place of a error stack trace.92939495 <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">9697 <error statusCode="403" redirect="NoAccess.htm" />9899 <error statusCode="404" redirect="FileNotFound.htm" />100101 </customErrors>102103 -->104105 <httpHandlers>106107 <remove verb="*" path="*.asmx"/>108109 <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>110111 <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>112113 <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364E35" validate="false"/>114115 </httpHandlers>116 <httpModules>117 </httpModules>118<membership>119120<providers>121122<remove name="AspNetSqlMembershipProvider"/>123124<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"125126connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true"127128applicationName="/ETS" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"129130minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />131132</providers>133134</membership>135136<profile>137138<providers>139140<add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />141142</providers>143144</profile>145146</system.web>147148</configuration>149
|||

You are welcome.

Modify the authentication and authorization tags to something like this:

<authentication mode="Forms"><forms name="appNameAuth" path="/" loginUrl="Login.aspx" protection="All" timeout="999999"> </forms></authentication><authorization> <deny users="?" /> </authorization>
good luck.
bullpit

|||

bullpit:

You are welcome.

Modify the authentication and authorization tags to something like this:

<authentication mode="Forms">
<forms name="appNameAuth" path="/" loginUrl="Login.aspx" protection="All" timeout="999999">
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
good luck.
bullpit

Thanks, replaced <authentication mode="Forms" /> with the code above but the exact same problem persists.

|||

Now I am not sure what the problem is. For creating users in your database, you can use the ASP.NET configuration tool to create and manage users, roles and other things. For me, for some reason, Create User option does not work, everything else works though. So what I do is add a temporary web page to my application with just a CreateUserWizard control on it, create a user, and then remove it from the project. For everything else, theres Master Card (ASP.NET Tool)

bullpit

No comments:

Post a Comment