Tuesday, July 1, 2008

Programmatically creating DotNetNuke portals - Part 1

If the need ever arises you can use C# to use the DotNetNuke API to programmatically create portals you can use the code listed below. Of course the code will need all the right permissions to do this. You will need the following information to create the portal.

  1. Portal Name
  2. Administrator first name and last name
  3. Administrator username and password
  4. Administrator email
  5. Portal description
  6. Portal Keywords
  7. Name (including path) of the template to the applied to the portal
  8. Portal Alias
  9. Server path (the path to the root of the Application)
  10. If it is a child portal the child path (the path to the child portal folder)

Listed below are the required steps to create the portal and perform some essential house keeping activities:

  1. Make sure that the alias does not contain the string "http://".
  2. Check if the required alias is available.
  3. Encrypt the administrator password with the machine encryption key.
  4. Get all the required paths: template path, home directory and server path.
  5. Create the portal.
  6. Add the new http alias (url) to the Http handler.
  7. Log the portal creation event tp DotNetNuke's event log.

In the next few days, I'll add a detailed post for each of the steps listed above.

Update 1: I've just posted an article on Programmatically checking if the required alias is available in DotNetNuke

Update 2: I've just posted an article on Programmatically creating DotNetNuke user passwords

5 comments:

  1. Would really love to see some c# code on how to create the portal!

    ReplyDelete
  2. I don't see "code". Am I missing something?

    ReplyDelete
  3. Treeluv, click on the hyperlinks of steps 1, 2 and 3 (Update 1 and Update 2)

    ReplyDelete
  4. I would love to see a example of step 4 i keep getting this error:

    Error parsing Portal TemplateViolation of UNIQUE KEY constraint 'IX_FolderPermission'. Cannot insert duplicate key in object 'dbo.FolderPermission'.

    ReplyDelete
  5. Sorry. I know this is old but I had to laugh. "How to programmatically create a portal". Step 5. Create the Portal. Yeah...you're good.

    ReplyDelete

Subscribe to my feed in your favorite feed reader