At first, I want to build a registering webpart. When the user register in my TopLevel Site, he will be added into my siteuser list and the system will create a subsite for him.

So in the CreateUserWizard_CreatedUser method I add some code like:
CreateComSites();//create a subsite
SetUserToTopSiteVisitor();//add the new user to topsite visitor group
SetUserToSubSiteAdmin();//add the new user to the subsite(which we created above) owner group

I use the  CreateUserWizard control for registering.

But the problem is, when the user visit the site at first time, he is anonymous. So after he click register button, the page will redirect to the login.aspx. And all of the code will not execute.

So my second plan is to build a individual asp.net site to manage the registering.

The code is very simple:
create a SPWeb instance of the TopLevel Site, use the SPWebCollecation.Add method.
It works excellently when the site is AD authentication.

And when I configure the site to form authentication, problem appears:

Sometimes I can create the subsite successfully though some exception catched.(when in AD authentication, it's the same)
Sometimes some exception catched with the same beginning with the above paragraphs such as
"System.NullReferenceException: Object reference not set to an instance of an object."
but different in detailed information.

I will show you the two exception:

1.the site created successfully in AD or Form.

System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.SPSite.get_Features() at Microsoft.SharePoint.SPElementProvider.QueryForWorkflowDefinitions(SPWeb web) at Microsoft.SharePoint.Workflow.SPWorkflowManager.RegisterFeatureTemplates(SPWorkflowTemplateCollection wftemplates, SPWeb web) at Microsoft.SharePoint.SPWeb.get_WorkflowTemplates() at Microsoft.SharePoint.Workflow.SPWorkflowAssociation.get_BaseTemplate() at Microsoft.SharePoint.Workflow.SPWorkflowAssociation.get_BaseTemplateInternal() at Microsoft.SharePoint.Workflow.SPWorkflowAssociation.SetTaskList(SPList list) at Microsoft.SharePoint.Workflow.SPWorkflowAssociationCollection.SetUtilityLists(SPWorkflowAssociation wa, Boolean forceUtilityListCreation) at Microsoft.SharePoint.Workflow.SPWorkflowAssociationCollection.AddCore(SPWorkflowAssociation wa, Guid id, SPList list, Boolean forceUtilityListCreation) at Microsoft.SharePoint.Workflow.SPContentTypeWorkflowAssociationCollection.AddCoreCT(SPWorkflowAssociation associationTemplate) at Microsoft.SharePoint.Workflow.SPContentTypeWorkflowAssociationCollection.UpdateOrAdd(SPWorkflowAssociation associationTemplate) at Microsoft.SharePoint.SPContentType.CopyWorkflowAssociationsTo(SPContentType ctDst) at Microsoft.SharePoint.SPWeb.SyncNewLists() at Microsoft.SharePoint.SPWeb.ApplyWebTemplate(String strWebTemplate) at Microsoft.SharePoint.SPSite.CreateWeb(String strUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere, Guid webId, Guid rootFolderId, Boolean createSystemCatalogs) at Microsoft.SharePoint.SPSite.SPWebCollectionProvider.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere) at Microsoft.SharePoint.SPWebCollection.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere) at _Default.Button1_Click(Object sender, EventArgs e)


2 .the site not created in Form

System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.Utilities.SPUtility.RedirectToAccessDeniedPage(HttpContext context) at Microsoft.SharePoint.Utilities.SPUtility.HandleAccessDenied(Exception ex) at Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAccessException ex) at Microsoft.SharePoint.Library.SPRequest.CreateWeb(String bstrUrl, String bstrTitle, String bstrDescription, UInt32 nLCID, String bstrWebTemplate, Boolean bCreateUniqueWeb, Boolean bConvertIfThere, Guid& pgWebId, Guid& pgRootFolderId, Boolean bCreateSystemCatalogs) at Microsoft.SharePoint.SPSite.CreateWeb(String strUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere, Guid webId, Guid rootFolderId, Boolean createSystemCatalogs) at Microsoft.SharePoint.SPSite.SPWebCollectionProvider.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere) at Microsoft.SharePoint.SPWebCollection.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere) at _Default.Button1_Click(Object sender, EventArgs e) in

If anyone know how to handle it or anyone meets the same problem, let me know.

posted on 2006-07-27 10:24  有些伤感  阅读(1229)  评论(0编辑  收藏  举报