Learn More





Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Programmatic Child Portal Creation sometimes does not completeProgrammatic Child Portal Creation sometimes does not complete
New Post
1/25/2015 3:22 PM

I've created a programmatic way to make child portals for a fund raising site that's worked fine for the past year.  Recently, we started getting only partially created portals in some cases.  It is thought that somehow this is happening on the ISP end.  BTW, the code for this is copied from the DNN source and set up to be used by lesser privileged users.  We're just about to go live and these "blank" portals started coming up!  Darn :)

The 2 "blank" child portals can be seen below.   What a testing user found was sometimes a site didn't get created so trying the same name again threw the error that the child portal name already exists.  But what really happens unbeknownst to them is the portal gets *partly* created.

I'm looking for some ideas of what would cause this.  There have been recent Microsoft patches to servers which might be a clue.  This code was created and working in Summer 2013 and working up until November or so 2014.

While it can be an ISP thing, I don't know of anyone else who's tried this.  It could be something got exposed with this new idea.  Thanks for any input.

New Post
1/25/2015 4:31 PM
Some more detail on this is the blank sites can't be found in the portal alias table. But the entries for them do exist in the Portals table. I'll be tracing what procedures aren't being completed -- there has to be something like "create portal alias" where the SQl code isn't completing for some reason and stops after the Portals table entry.

I'm also in touch with the ISP on this one.
New Post
1/25/2015 6:19 PM
Looked into dependencies for the Portal Alias table. it's evident the stored procedure AddPortalAlias is never being fired. There is nothing in the procedure where it would terminate itself.

Also, looking at the blank portal alias entries, the Last Modified On date is 2 seconds or so after the Created On date. Taking the top 5 Portal IDs from Portals where there is an entry in Portal Alias, the Last Modified On date is 2 minutes or more recent than the Created On date.

So, something is firing the procedure in most cases but for the 5 portals where the Site Alias in the Host Settings Site Management is blank, something's terminating that process a few seconds into the child portal creation sequence.

Here is the data for the failed portals, followed by the top five successes by Portal Id:

PortalId GUID AdministratorRoleId RegisteredRoleId CreatedOnDate LastModifiedOnDate
1050 73763A93-8346-44D7-B65C-F050C4C70040 2483 2487 2015-01-19 10:49:09.973 2015-01-19 10:49:11.397
1051 EFD647F7-4482-475D-B618-8C63AB9C0DD3 2494 2498 2015-01-22 18:53:08.640 2015-01-22 18:53:10.070
1052 6F4A1AB5-5A80-426C-B7DF-66D82E67F71D 2505 2509 2015-01-22 18:55:51.740 2015-01-22 18:55:52.823
1053 AC0C363D-96F5-4D76-AA0B-3A548D6C48AA 2516 2520 2015-01-22 21:02:16.957 2015-01-22 21:02:17.930
1054 6F104AD8-D884-4D5A-A29B-C05EA6CF4D53 2527 2531 2015-01-24 10:38:58.187 2015-01-24 10:38:59.320
PortalId GUID AdministratorRoleId RegisteredRoleId CreatedOnDate LastModifiedOnDate
1055 3921AC3C-68D8-41DB-85B3-22C551D91C3C 2538 2542 2015-01-24 10:42:40.317 2015-01-24 10:44:30.747
1049 641FD403-486D-4794-95AF-60D7ACB5178D 2472 2476 2015-01-18 10:09:42.690 2015-01-18 10:11:23.687
1048 D7A5E761-AE4A-40CB-B61E-A10EE0193A6B 2461 2465 2015-01-15 16:28:37.963 2015-01-15 16:29:57.680
1047 00E1FFE1-E51B-4737-B0C6-06465452CBD5 2450 2454 2015-01-14 15:48:51.507 2015-01-14 15:50:08.923
1045 95108BAA-6714-481F-929A-F4AD8AC9BBC1 2428 2432 2015-01-13 20:54:06.073 2015-01-13 20:55:35.667

Information on the processing steps on the database side will help. I might need to write a work around where if I get a Portal ID back to the C# code but don't get a corresponding Portal Alias ID then do the procedure again, etc. Or, simpler, when this happens put a means for the sales rep user who creates portals to delete that child portal and start over.

What I'd like to do is write the code on the database end, if possible, to find what didn't fire after a failure. Then just clean it all up on the back end and either re-fire the sequence or give the end user a friendly error message that it didn't work and try again. The latter is probably the safest approach.

Open to any ideas ... Thanks!
New Post
1/31/2015 3:32 PM
Accepted Answer 

Alright folks ... I'll answer it myself.

While it isn't known what is causing the portal create process to stall, it is known what the work around is: Delete the errant attempt and start over.

Since it is known that when the error happens there is no entry in Portal Alias, this code is needed:

        /// <summary>
        /// Checks that the Portal Alias table has an entry
        /// for a newly created portal.  HttpAlias will be blank
        /// if the portal creation process did not follow through
        /// </summary>
        /// <param name="portalId">PortalId</param>
        /// <returns>httpAlias</returns>
        public string ValidatePortalAliasCreate(int portalId)
            string httpAlias = "";
            using (SqlConnection sqlConnection1 = new SqlConnection(connectionString))
                using (SqlCommand cmd = new SqlCommand())
                    cmd.CommandText = "ABFR_SP_(sproc name deleted)";
                    cmd.Parameters.AddWithValue("PortalId", portalId);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection = sqlConnection1;
                    SqlDataReader reader = cmd.ExecuteReader();
                    httpAlias = reader.GetValue(reader.GetOrdinal("HTTPAlias")).ToString();
            return httpAlias;

This is called from the programmatic child portal creation code as shown:

                            intPortalId = objPortalController.CreatePortal(txtPortalName.Text,


We'll get the portal id in Portals regardless of whether the Portal Alias entry happened or not, so now we test it:

                            //Validate that the portal was created and an HttpAlias entry was made
                            if (String.IsNullOrEmpty(dataAccess.ValidatePortalAliasCreate(intPortalId)))
                                DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "", "Error creating portal, no entry found in Portal Alias for "
                                    + txtPortalName.Text + "." + " Portal will now be deleted.  Please try creating the portal again with the same information."
                                    , ModuleMessage.ModuleMessageType.RedError);
                                //Delete the Portal
                                var objDeletePortalController = new PortalController();
                                var portal = objDeletePortalController.GetPortal(intPortalId);
                                if (portal != null) PortalController.DeletePortal(portal, Globals.GetAbsoluteServerPath(Request));
                                //Throw exception to prevent the catalook settings, etc. from happening.
                                throw new Exception("Error creating portal, no entry found in Portal Alias for " + txtPortalName.Text
                                   + "." + " Portal has been automatically deleted.");

It was thought the code to remove the portal was going to be hard to implement for this purpose but it's very straightforward.

The code was tested by negating the String.IsNullOrEmpty() call to the data access method.  This is the result:

I don't know that anyone would be doing the same routine we are where we need to programmatically create fund raisers in their own child portals but this is what we've run into.  Unable to track down the specific database culprit, the work around here does provide a path forward.

The delete is clean and what's really great is the same entry data in the form (not fully shown) is persisted.  So, the corrupted portal is deleted and the same info for a fund raiser can be reinserted.

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Programmatic Child Portal Creation sometimes does not completeProgrammatic Child Portal Creation sometimes does not complete

These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
Try Evoq
For Free
Start Free Trial
a Demo
See Evoq Live
Need More Information?