0

I always struggle to find out that how to know what site definition or site template a "Web" or a "Site" is using. We do have a lot of custom site definitions and site templates, we are using in our portal, so If there is any freeware tool or way to find out, would be great.

We keep records of Site Templates in Database, but I want to know if there is any way, I find it out using a C# script or simply any app.

Cheers

2 Answers 2

2

Run the following code in your C# Console Application and you'll get the listing all your sub-sites with their respective site definitions

using (SPSite ospSite = new SPSite("http://server/"))
{
    SPWebCollection webs = ospSite.AllWebs;
    foreach (SPWeb web in webs)
    {

       try
       {
          string template = web.WebTemplate;
          Console.WriteLine(web.Url.ToString() + " : " template.ToString());
       }
       finally {web.Dispose();}
    }

 }
2
  • Cheers brother done it, I was wondering if you have any twitter account or LinkedIn , i can follow you :) Jun 26, 2012 at 8:31
  • 1
    As I say it, follow me at your own risk ;) twitter.com/#!/falaky Jun 26, 2012 at 8:34
1

Use SPWeb.WebTemplate property.

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.