Wednesday, March 7, 2012

Deploying a website with user authentication - getting errors

I have built a site that uses form-based authentication. Am I correct in assuming that the users and passwords will be stored in the SQLServer database in the aspnetdb.mdf file? The website works great and the authentication works how I want it to. However, I've tried to copy over the file onto a remote machine. The first page is a login screen and this is displayed without any problems but as soon as I attempt to log in I get an error message of:

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)


I'm wondering if this is something to do with the fact I installed SQLServer Express edition on the remote machine. The website works no problem on the local machine in debug mode of Visual Studio 2005 (Professional Edition). I followed instructions to enable remote connections on SQLServer Express from a Microsoft support doc. If anybody can point me in the right direction I'll be very grateful as I've hit a wall here.

Did you check the connection string in web.config if it is pointing to the right server. Also, if you are using aspnetdb.mdf, you should have at least SQL Server Express edition installed on the machine hosting the website.

|||

Hi. Thanks for replying. The only connection string I have in my webconfig file is for an Oracle database that I access elsewhere in the website. Since the original website works in the debug mode of Vis Studio 2005 without any other connection string then I just copied the webconfig file over to the remote server as it was. Does that mean I have to add a connection string to the aspnetdb.mdf file? (The server has SQLServer Express installed on it.)

|||

Have a look at this and try adding a connectionstring to the server.
https://help.maximumasp.com/SmarterTicket/Customer/KBArticle.aspx?articleid=878

You might have to attach the local mdf file using this in the connection string.

AttachDBFilename=|DataDirectory|aspnet.mdf 
connectionStrings> <remove name="LocalSqlServer" /> <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/></connectionStrings>

No comments:

Post a Comment