I am working on a portal and have a site/web and I am trying to find out what site definition its using, I tried this code to find out, it does give me a site template ID and Master page URL, but it Site definition is blank, I was wondering if its possible that there is a site without any site definition.

I am using this code

   using (SPSite mySite = new SPSite(PageUrl))
            using (SPWeb web = mySite.OpenWeb())
                Console.WriteLine("Site definition: {0}", web.WebTemplate); // BLOG
                Console.WriteLine("Web template ID: {0}", web.WebTemplateId); // 9
                Console.WriteLine("Master Page : {0}", web.MasterUrl); // 9

it did worked for me many times before tho.

1 Answer 1


It is not possible. All webs have site definition. The name of definition you can get by this code:

string id = string.Format("{0}#{1}", web.WebTemplate, web.Configuration)

To see what definition is used you can compare result string with values in this post.

  • thanks for your answer, but when i Use "web.Configuration" it gives me "0" Jul 5, 2012 at 7:46
  • it is normal behavior. What kind of WebTemplate do you have?
    – Alexander
    Jul 5, 2012 at 7:49
  • WebTemplate id is "10016" and am not sure how can i find "kind" of WebTemplate is being used :( Jul 5, 2012 at 7:53
  • I looked at the post, I Know about configuration, but each site definition have some kind of name, it never should come up as null, unless its not being used Jul 5, 2012 at 7:54
  • its STS Team Site, if thats what you were asking for :) Jul 5, 2012 at 7:56

Your Answer

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

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