0

Newbie to ASP.NET.

In visual Studio 2010 Ultimate I created a new ASP.Net 3.5 website and then added forms authentication using toolbox controls dropped on to the page. After creating a new user using these controls in my test environment a database was created called ASPNETDB.MDF inside the App_Data folder of the project.

I also made modifications to this database by adding tables to it that I access in code from web forms on the site using connection string:

Data Source=.\SQLEXPRESS;AttachDbFilename=C|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True

Now I am ready to put the site on my web host, 1and1.com. I created a database in the 1and1 Control Panel. The 1and1 help pages says to use a connection string like the following to connect to a 1and1 hosted SQL Server database:

server=mydbHostName.db.1and1.com; initial catalog=mydbName;uid=mydbUser;pwd=mydbPassword

I have tested this connection and can create and access tables using this connect string.

My question is how do I tell forms authentication to use this new database on the 1and1 server?

2 Answers 2

1

It's all in your web.config file. You should see something that looks like:

<membership defaultProvider="DefaultMembershipProvider">
      <providers>
        <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" <snip> applicationName="/" />
      </providers>
    </membership>

The connectionStringName points to a connection string defined in the ConnectionStrings section - just make sure you change the property in the Membership Provider to match the name you used for the connection string (or vice versa).

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. To make this work I need to import (or create) the database into the 1and1 server. Is there an easy way to do this? 1and1 can accept a .bak file. I tried to create a SQL script to create the schema on the 1and1 server but ran into 'collation conflict' errors which are hard to track down. Again, is there an easy way to do this?
Finally got it to work. For anyone else trying to get ASP forms authentication or member database schema onto a 1and1 server, first run C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql.exe -S mydbHostName.db.1and1.com -sqlexportonly script.sql -A all -d mydbName -U mydbUserID -P mydbPassword with your information in place of the 'mydb...' parameters. Then open the script.sql file it creates. Then copy and paste it's contents into the Query Analyser inside the database tools then hit submit, wait for a minute or so and done.
0

Well, that's really a different question, but anyway - you can create a database backup using the BACKUP command through SSMS or by right-clicking on the database in SSMS and select Back Up from the tasks menu - this will create your .bak file which you can upload to 1and1 using FTP. Then go into their SQL manager, or connect to your SQL Server instance with SSMS (I'm not a 1and1 user, but most hosts let you connect using your SQL Server credentials from your hosting account), and restore the database from the .bak file. Without examining your script and the 1and1 SQL Server configuration, I couldn't tell you why you had collation errors - could be a difference between SQLExpress (which is the default for ASP.Net profile management) and whatever version of SQL Server 1and1 is running. You may not have Create Database privileges on the 1and1 server without going through their web-based tool in any case. Once you have the database attached to the 1and1 server, your application should connect using the connection string they provided - just make sure you have the server location and database name correct.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.