SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
thanks for your answer, but when i Use "web.Configuration" it gives me "0" – Muhammad Raja Jul 5 '12 at 7:46
it is normal behavior. What kind of WebTemplate do you have? – Alexander Jul 5 '12 at 7:49
WebTemplate id is "10016" and am not sure how can i find "kind" of WebTemplate is being used :( – Muhammad Raja Jul 5 '12 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 – Muhammad Raja Jul 5 '12 at 7:54
its STS Team Site, if thats what you were asking for :) – Muhammad Raja Jul 5 '12 at 7:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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