In this article I will explain about how to create web for your own site with small amount of code.
To Create web for your site
Open Visual studio - File - Create New project
then select C# as the language and Console Application from the panel.
Give CreateWeb as name for project, then click ok.
After Creating the project, you need to add the Sharepoint DLL for your project.
For this right click on solution Explorer and select Add Reference . Browse for Microsoft.Sharepoint.dll file and click ok.
With default installation of Sharepoint, you can find this dll file at below location.
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\Microsoft.SharePoint.dll
So, you successfully establish the environment to create web for your Sharepoint site.
The code to create your own web for your sharepoint site look like below.
using System; using System.Collections.Generic; using System.Text; using Microsoft.SharePoint; namespace CreateWeb { class Program { static void Main(string[] args) { SPSite rootsite = new SPSite("http://home-pt72rbbzr0/sites/FirstTestSite"); SPWebTemplateCollection webTemps = rootsite.GetWebTemplates(1033); SPWebTemplate blogTemp = webTemps["BLOG#0"]; SPWeb wikiWeb = rootsite.AllWebs.Add("BLOG", "BLOG web", "This is the blog for the new site", 1033, blogTemp, false, false); } } }
In the above code http://home-pt72rbbzr0/sites/FirstTestSite is the my own site URL(you can give your own sharepoint site URL).
Here we created web for Blog of the given site.
We write the code to create web, then we need to deploy it on production server.
If the production server is same as develop server, then just press F5, if not you need to copy the entire project to production server and install or deploying your code using various deployment methods in .Net Framework and install on server.
After installing the above project, open new Browser window with http://home-pt72rbbzr0/sites/FirstTestSite/blog , then you can find that your new web which was just created will display like below.