I am working on building an event receiver inside my sharepoint server 2013.
now i have the following structure:-
- site collection url =
http://servrname/kb/pmo
- sub-site url =
http://servername/kb/pmo/projects/
- inside the subsite i have a list named "projects". where i define an event receiver which will fire when the item is added. and the event receiver will create a sub-site under the projects. such as "
http://servername/kb/pmo/projects/SubSiteA
"
here is the related code inside my event receiver which is scoped at the web level:-
public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(properties.SiteId))
{
string currentweburl = properties.WebUrl;
using (SPWeb spCurrentSite = site.OpenWeb(currentweburl))
{
//code goes here
SPWeb newSite = spCurrentSite.Webs.Add(curItemSiteName, curItemSiteName, "123", Convert.ToUInt16(1033), webTemplate, false, false);
newSite.Update();
newSite.Close();
But I am getting this strange error on the last line (when I am trying to create a new SPWeb)
<nativehr>0x80070002</nativehr><nativestack></nativestack>There is no Web named "/kb/pmo/http://servername/kb/pmo/projects".
so can anyone advice on this please?
Thanks