Tuesday, March 17, 2009

DotNetNuke – Installing DNN 5 with VS 2008

Prerequisites:

  • Visual Studio (I am using 2008, you could use 2005).
  • SQL Server 2005 Express. (Needs to be installed with Mixed Mode Authentication)
  • DNN Source (Either the Install package or the Starter Kit. If you are using the Starter Kit, install the starter kit so that it becomes integrated into VS).
    Get the latest version of DNN from CodePlex. (I am currently using v5.00.01)

Creating a Database.

When using SQL Server, there are 2 ways in which you can setup your database:

  1. Attached database file:
    This is the simplest method of working with DNN. The database file is created within the DNN install folder and you typically dont have to do anything. Even though this is the easiest option, I find creating a database within your DB server is easier to develop with, as you can use the SQL Server Management Studio to work with the database.
  2. Database attached to the server:
    As written above, this is my preferred DB setup for DNN. This is because you can easily use SQL Server Management Studio to work with the database (adding tables, stored procs, etc.). Here is what you need to do:
  3. A. Create a database
    Right click on the Database node and select “New Database….”image
    In the New Database dialog, type a name for the database and click OK.
    B. Create a Login
    Right click on the Security\Login node and select “New Login…” image
    In the New Login dialog, type a name for the login, set the login type to SQL Server Authentication and set the password. Click OK.
    image 
    C. Create a User for the DNN database
    Navigate to the Security\Users node under the database you created in step (A). Right click and select “New User…”
    image
    In the New User dialog, type in a user name and select the login that you created in step (B) as the login name. Also, set “db_owner” as the “schemas owned by this user” and as the “database role membership”. Click OK.
    image 
    That will create a database that can be used by your DNN install.

    D. The connection string:
    The connection string will look like this:
    Data Source=localhost\SQLEXPRESS;Initial Catalog=dnn5DB;Persist Security Info=True;User ID=dnnLogin;Password=dnnLoginPwd;
    where dnn5DB is the name of the database, dnnLogin is the name of the user and dnnLoginPwd is the password for the user.
    You will have to update the bolded text in the code above to create a connection string specify to your settings.

Installing the DotNetNuke Source

Again, there are 2 major ways you can go about installing the DNN source to your machine:

  1. Use the DNN Install package
    This is probably the simplest method for installing DNN to your machine.
    The package you need for this, is typically called “DotNetNuke_Community_05.00.01_Install.zip”. Once you have downloaded the package, you need to unzip the contents to a folder on your machine. I prefer working with IIS server instead of with Cassini (the integrated web dev server in VS). This is because it makes it easier to find errors that you wouldn't otherwise come across until you push your code to the production server. Unzip the contents to a folder under “c:\inetpub\wwwRoot\”.
  2. Use the DNN starter kit for Visual Studio
    To use this option you need to download the starter kit (DotNetNuke_Community_05.00.01_StarterKit.vsi) and first install it on to your machine. I prefer this method as it makes it easy to create multiple DNN installations on your machine. Once you have installed the starter kit, start up Visual Studio and go to New->Website. (Remember I am using VS 2008, so my steps might differ slightly if you are using VS 2005).
    image
    In the new web-site dialog, first select “Visual Basic” as the language (dont worry you will still be able to use C# as your language for creating modules). Once you have selected VB as the language you will see “DotNetNuke We Application Framework” under my templates. Select it. Now set the location to “HTTP” and set the location as “HTTP://localHost/FolderName” (where folder name must be provided by you).
    image
    The reason we use HTTP is that we wish to use IIS to host our DNN application. (Alternatively, you could install using a folder on the file-system and create a virtual directory in IIS that points to that folder).
    Click OK. VS will churn for a bit, creating files on your machine. If you set the location as “Http://localHost/someLocation”, then the files will get created in “c:\inetPub\wwwRoot\someLocation”.
    VS2008: Once done, Visual Studio 2008 will ask you if you would like to upgrade the project to use .Net Framework 3.5. Answer No. On my machine whenever I answered Yes, the project would become unusable and VS would shut down everytime I tried to open the solution. You can select the target framework later.
    image

Updating web.config

If you using the attached database file option then you can skip this step (this is the option where a database.mdf file is used in the app_data folder of your installation directory). Remember I prefer having my database attached to the server. As I have already setup a database to be used with my DNN installation, I am going to update the web.config file with the new connection string (remember, we created this in step (D) above).

Open web.config:
- look for “SiteSQLServer” under the <connectionStrings> node. Update the connectionString for property for “SiteSQLServer” with the new connection string from step (D).
- look for “SiteSQLServer” under the <appSettings> node. Update its value to the new connection string from step (D).

My updated settings look like this:

<connectionStrings>
    <add name="SiteSqlServer" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=dnn5DB;Persist Security Info=True;User ID=dnnLogin;Password=dnnLogin;" />
  </connectionStrings>
  <appSettings>
    <add key="SiteSqlServer" value="Data Source=localhost\SQLEXPRESS;Initial Catalog=dnn5DB;Persist Security Info=True;User ID=dnnLogin;Password=dnnLogin;" />

Setting up file permissions

The next thing you need to do is to setup folder permissions, so that the user running the web-site has access to the folder. The user that is used for this is typically named ASPNET.

Navigate to the folder where the DNN source code was installed. (Typically c:\inetpub\wwwroot). Right click on the folder containing the DNN source code and select properties. Next select the Security tab and click the Add button.
image 
Click locations and select the node that represents your computer (typically the top-most node) and then click OK. Type ASPNET in the text box and click “Check Names”. ASPNET, should change to a fully qualified name on your machine. Click OK.
image
With ASPNet account selected, click on the Modify permission (the other permissions should automatically get enabled).
image
Click on “Advanced”. Put a check on “Replace permissions on all child objects….” and click OK. (Answer yes, if you get a dialog asking you if you are sure).
image
Click OK in the Folder Properties dialog.

Setting up IIS settings

When you DNN web application is run, you need to tell IIS, which file needs to be opened by default. To do this, open up IIS Manager (found under Control Panel->Administrative Settings)
image 
Right click on the node representing the DNN web-app and select properties.image 
(if the node does not look like a web-app, then you need to click the Create button to make the folder in to a web-app image )
Select the Documents tab. If you do not see “default.aspx” in the list, then click Add, type “default.aspx” and click OK. Use the arrow keys on the left to move “Default.aspx” to the top.
image

Setting up DotNetNuke

DotNetNuke is installed using DotNetNuke!. When you run DNN for the very first time, it will detect that it needs to install the database tables, stored procs, etc, as well as configure the website, so that it can be used.

Run DNN by hitting CTRL + F5. (or Debug-> Start Without Debugging).
image 
This is the moment of truth. If you installed everything correctly and setup permissions correctly, you should see the following web-page:
image
Select “Typical” and click next.

On the next page, test the file permissions and make sure that all checks are passed:
image
Click Next.

If you correctly updated your web.config file, then all the settings should automatically be populated into the Database configuration dialog. (If you are using the attached database option, the fields highlighted in yellow will have different values).

Enter the password. Select “Run as db Owner” and enter an object qualifier. (The object qualifier is a prefix that is applied to every object added to the database, this is extremely useful, when your database might hold objects from multiple apps, etc. Choose a short prefix: eg. dnn5)

image

Make sure that you test the database connection and that the test passes. Click Next.

The website will churn for a bit and then respond that it successfully managed to create the database. Click Next
image

In the next screen you need to configure the Host account. You need to provide a password, as well as an email address (even if you do not set the SMTP server). Click Next.
image

On the next screen you need to setup the admin account.
image
Click Next.

The next screen is your final confirmation screen that your installation ran ok.image

If you get the above screen, you can click on the “Go to website” link, which will take you to the home page of your newly installed DNN portal.
image

At this point you should be able to login to your DNN portal using your host account.

Note:

If you get an error similar to “Could not load type 'DotNetNuke.HtmlEditor.FckHtmlEditorProvider.fcklinkgallery'” when you build your web-site, it is because in some versions (5.00.00) of DNN source/starter kit, the “DotNetNuke.FckHtmlEditorProvider.dll” was being deployed to the “Bin\Providers” folder instead of the “Bin” folder. If you move the dll from the providers folder to the parent bin folder, you should be able to successfully build DNN. This issue has been fixed with version 5.00.01 of DNN.

5 comments:

oldirtdog said...

This is an awesome write-up... everything worked perfectly and I did it the way you recommended... however, I need to make one note: when I tested my database connection, I got an error stating that the login failed... I verified my user/pass and it was all good... I had to change the security of the actual SQL server to allow SQL authentication as the Windows Authentication is the selected default option... pretty easy fix, but caused me a slight headache for 15 minutes...

Otherwise, thanks for what you do!

Anonymous said...

Thanks much for your efort

Anonymous said...

Hi bro,
Can you tell me why i can't see the DNN module when i start new website. I used installed package to intall DNN.
Thanks in advance.

AD said...

Hey can you tell me how to install module in VS2010 beta 2. Starter kit installation fails in VS 2010.
This will be really helpful

Brian said...

My setup is VS 2008 and SQLEXPRESS 2008. I followed the instructions and I receive an error System.Data.SqlClient.SqlException: Cannot find the user 'dnnLogin', because it does not exist or you do not have permission.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(SqlConnection connection, CommandType commandType, String commandText, SqlParameter[] commandParameters)
at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters)
at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText)
at DotNetNuke.Data.SqlDataProvider.GrantStoredProceduresPermission(String Permission, String LoginOrRole)

GRANT EXECUTE TO [dnnLogin]

I checked that the dnnLogin in the database has a schema & role of db_owner and also the I've been trying to track down the solution but to no avail. From what I've been reading, I looks like it's something with ownership of the tables but I'm not sure how to proceed or even if that is the issue. Any help would be great.

Thanks,

Brian