We have sharepoint 2010 foundation server for development and enterprise edition in live. We have one .NET web part which create a site based on the logic which works fine in development server(Foundation). Same code we used in live(Enterprise edition) creates the site first time but not the second time.
What is our problem here? I shared the code which create the site
private void CreateNewSite(SPWeb web, string sSiteName,string sSiteTemplate)
{
string sSiteUrl = web.Url + "/" + sSiteName;
if (!SiteExists(sSiteUrl))
{
try
{
web.AllowUnsafeUpdates = true;
string url = sSiteName;
string title = sSiteName;
string description = sSiteName + " Site Testing";
string type = System.Configuration.ConfigurationSettings.AppSettings["SiteTemplateId"];
// Site creation with unique permissions
SPWebCollection webs = web.Webs;
SPWeb newWeb = webs.Add(url, title, description, 1033, type, true, false);
newWeb.Navigation.UseShared = true;
//Adds to site navigation
SPNavigation nav = newWeb.ParentWeb.Navigation;
SPNavigationNode node = new SPNavigationNode(newWeb.Title, newWeb.ServerRelativeUrl);
node = nav.AddToQuickLaunch(node, SPQuickLaunchHeading.Sites);
//Adds to top quick link
SPNavigationNodeCollection topnav = web.Navigation.TopNavigationBar;
node = topnav.AddAsLast(node);
// Changing the request access email to current user
newWeb.RequestAccessEmail = newWeb.CurrentUser.Email;
// Save changes
newWeb.Update();
newWeb.Close();
// Disposing new web object
//newWeb.Dispose();
}
catch (Exception ex)
{
throw ex;
}
finally
{
web.AllowUnsafeUpdates = false;
}
}
}