I have write code in Feature Receiver to Create SubSite but while Feature is activating it returns the error

http://pc31:2000 contains illegal character ':'.

This is My Code where I got Error. can anyone help me?

SPWeb newWeb = site.AllWebs.Add(web1.Url, "Custom Site", "Site description", 
    1033, "Publishing Site", true, false);

1 Answer 1


You need to specify the relative url of the new site as the first parameter to the AllWebs.Add() function. Have a look here:


A string that contains the new website URL relative to the root website in the site collection. For example, to create a website at http://intranet.contoso.com/sites/MySiteCollection/MyNewWebsite, specify MyNewWebsite, or to create a website one level lower at http://intranet.contoso.com/sites/MySiteCollection/Website/MyNewWebsite, specify Website/MyNewWebsite.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.