How to Set Up Forms Authentication for Your ASP.NET Web Site

This article assumes you have developed an ASP.NET application that uses Forms Authentication that you wish to deploy on Arvixe. The process is quite simple and you will use tools that are available from the .NET framework and the Arvixe DotNetPanel.

  1. Log in to your DotNetPanel.
  2. From the menu, select DatabasesSQL Server 2008.
  3. Click the Create User button.
  4. Enter a user name and password and click Save. In this demonstration, the user name is dotnetuser and the password is dotnetuserpass.
  5. Click the Create Database button.
  6. Enter a database name and grant access to the user you created above and click Save. In this demonstration the database is called DotNetAuthentication.
  7. Locate and run the ASP.NET SQL Server Setup Wizard. This file is located in your .NET framework directory and is named aspnet_regsql.exe (example: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regsql.exe).
  8. Click Next and choose Configure SQL Server for application services.
  9. Click Next and enter the server name and database log in credentials. The server name is the web site pointer address to where your application will be published and the log in credentials are the SQL server user name and password created earlier. In this demonstration, I have a web site named demoaspnetregsql and its web site pointer address is demoaspnetregsql.com.iris.arvixe.com. The database name is the one created earlier, which is DotNetAuthentication.
  10. Click Next twice and the wizard will take a moment to complete the scripting actions that populate the new database with all the objects necessary to configure the ASP.NET provider.  Once complete, click Finish to close the wizard.
  11. Finally, modify the web.config file in your ASP.NET web application to use the database you created.  When I deploy my application to the Arvixe host server, I change the value for the connection string to the following:
Data Source=(local)\sqlexpress;Initial Catalog=DotNetAuthentication;Integrated Security=no;User ID=dotnetuser;
Password=dotnetuserpass;

That’s all there is to it! If you need information on how to configure Forms Authentication in your ASP.NET application, please review this article from Microsoft or this article from 4guysfromrolla.com.

Tags: , , , , , , , , , | Posted under ASP .NET 2, ASP .NET 3.5, DotNet/Windows Hosting, MSSQL, Programming/Coding, Using Arvixe | RSS 2.0

11 Comments on How to Set Up Forms Authentication for Your ASP.NET Web Site

  1. Jibran says:

    Great to know that if I want a separate membership database I can do it this way. However, I was trying to create the tables and SPs inside my current database using the utility but could not get the Database drop down to display databases for me to pick mine. I kept getting the following error:

    —————————
    Connection failed
    —————————
    Failed to query a list of database names from the SQL server.
    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified)

    It would be nice to know if anyone found a way around it.

    • The drop down that’s being referred to in this article (I may be wrong), is the databases available in the local MSSQL database so if you are getting a connection failure for that, then you don’t have a proper instance of SQL server running locally or the app is not able to access it.

  2. Craig Rorrer Craig Rorrer says:

    Jibran,
    Based on the error message,it definitely sounds like the issue is with the server name entered. You should be able to enter either your domain name (ex: mydomain.com), the “temporary web site pointer address” (ex: mysite.com.iris.arvixe.com), or the IP address of your host server. I’ve tried all three methods and was successfully able to get the drop-down list to populate with the list of databases available from my Arvixe-hosted SQL Server. My suggestion is that you log in to your DotNetPanel and select Websites, then select your site and then try using the IP address that is printed at the top of the page.

  3. Jibran says:

    Craig,

    Yeah that is what I thought that may be I am getting the instance name wrong and they might be using a different instance name than SQLEXPRESS. However, I confirmed it from the support and that is the instance name. I think it may have something to do with the Configuration of Remote Access on their side. I am able to remote access my database from both Management Studio and Visual Studio; however, I can’t get this to work. Not a big problem, I end up doing it on the local server and Arvixe Support was kind enough to backup my .bak file. Still it would be nice to have that functionality.

    FYI, I did try the suggestions you made in your last post to test it out really quickly but now I am getting the following error.

    —————————

    Query database list failed
    —————————
    Failed to query a list of database names from the SQL server.
    Invalid object name ‘sysdatabases’.
    —————————
    OK
    —————————

    I do have a question for you though, are you creating an embedded membership database in the App_Data folder through your method or does it actually creates one on the server? Because it sounds like that is what you’ll end up getting through this method. As a personal preference I tend to avoid any embedded databases in Web Applications.

    Thanks for the help, I’ll troubleshoot this further once I am done with my current project and post and update on your post.

  4. Craig Rorrer Craig Rorrer says:

    Jibran,

    No, it didn’t create an embedded database as you mentioned… in fact, I was getting an error when my ASP.NET 2010 project tried to create an embedded database through its default membership implementation… that is why I stumbled on to this approach instead. I am not sure why it works for me but I would appreciate you following up and finding out what the issue is you’re having. One other thing to note is that when I first went through this method, I didn’t bother with using the drop-down to select the database. I just typed in the database name that I had already created on the server. According to the instructions, the wizard will either create a new database if it doesn’t exist, or update an existing one with the new objects.

    It seems like you resolved the server error based on the last error message you posted. Perhaps you can try typing in the database name manually as I did to see if that works. It still won’t explain why I can populate the drop-down in the wizard while you can’t,. My best guess for the last error message is that the wizard was able to connect to the SQL Server instance on your server but did not have the necessary permissions to query for the list of databases. Regardless, please let me know what you find out.

    Craig

  5. Chuck says:

    Craig,

    You sir are a genius! I am new to Arvixe and I was uploading my shiny new website and ran into problems with the membership data store that you describe here.I had used a sql script to move over the membership tables and that was a big mistake but after following your (genius) article I was able to make it work. I had already tried aspnet_regsql but your eample of what to put in the Server box was what really did the trick (demoaspnetregsql.com.iris.arvixe.com) – I had put just the last part for my server.

    Thanks!

  6. Dan says:

    Just wanted to say thanks! Your instructions worked perfectly!

    Thanks,
    Dan

    Running ASP.NET 4.0, Forms Authentication

  7. It seems like you resolved the server error based on the last error message you posted.

  8. Tom says:

    I had to manually type in the Database name.

  9. Very interesting and informational.

  10. It should be mentined if it hasn’t already that when registering your sql database do not click the down arrow for choosing your database. I have never had it return a list yet, always an error. Instead, when you get to that point just type in the name of the database manually that you created for this purpose then click next. Wallah! Job done. Now adjust your connection strings and register membership/role provider in your web.config.

Leave a Reply

Your email address will not be published. Required fields are marked *


× 7 = 42

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>