简体   繁体   中英

Assigning ASP.NET user/forms authentication database

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?

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM