Sharepoint 2010: Create site from site template where alternate CSS url is set – unexpected error occured accessing site settings

By peter.stilgoe

When you create a site template in Sharepoint 2010 where the template is taken from a site that has an alternate CSS url set, you find on the newly created site that when you try & access ‘Site Settings’ or ‘View all site content’ you get the ‘An unexpected error occured’.

In your logs you get something like:

System.Web.HttpException: Error executing child request for /sites/SiteName/Style Library/site-style.css

This appears to be a bug, you can fix the site by running the following Powershell script:

$w = Get-SPWeb http://YourServer/YourWeb; $w.AlternateHeader = $null; $w.Update()


, , ,

About... peter.stilgoe

peter.stilgoeThis author published 515 posts in this site.
Sharepoint, InfoPath, K2, Nintex, Business Process Mapping, Business Intelligence, Automation, ECM, Document Management, Document Imaging, Internet Marketing & Online Business Consultant Email / MSN: LinkedIn: Pete Stilgoe - Sharepoint Consultant


FacebookTwitterEmailWindows LiveTechnoratiDeliciousDiggStumbleponMyspaceLikedin


  • At 2011.04.27 23:39, mohsin said:

    i dont see any difference after executing this statement, the error is still there


    • At 2011.06.22 08:46, Alf said:

      It worked for our farm. I had 4 sites in this situation and worked for them all. Thank you!


      • At 2011.06.28 06:34, Carrie said:

        Sweet! This does the job. Any idea if this issue is fixed by a cumulative patch from microsoft?



        peter.stilgoe Reply:

        If its not in the very latest Sharepoint 2010 Cumulative update the no, I find it strange they havnt released a fix for it yet tbh


        • At 2011.07.01 08:48, Pub said:

          same problem here.
          After executing you’re fix the problem went gone.
          But every time we make a new site, the problem still exists and we must execute the fix again.
          Hopefully Microsoft will release a permanent fix for this.


          • At 2011.08.10 14:49, Tmark86 said:

            Thank you so much. I made a template and created about 50 sites from it. I thought I would have to go back and manually create each one. This script worked perfectly and fixed all of my sites.

            You are a life saver! Add me as one more for wanting a permanent fix for this simple issue.


            • At 2011.08.10 18:01, John said:

              running the script did fix the issue on a site already created. I wasn’t able to use it to fix the site the template was created from, but, I was able to save the template file (.wsp) to my local machine, unpack it (with 7-zip), then do a search for the string “alternateCssUrl” in all the files – it will find it in a couple of files – remove the value specified (so it reads like AlternateCssUrl=”"
              Then re-package the files (re-creating the WSP) by following these instructions (it’s not too difficult)
              and then upload that template to the solution gallery.

              What a hassle!


              • At 2011.10.05 21:13, Arley said:

                Hi Peter. Thanks. It works for me.


                • [...] Pete wrote a PowerShell script to fix the problem afterwards: [...]

                  • [...] http://world wide… [...]

                    • At 2012.12.04 17:07, tristian o'brien said:

                      worked for me,


                      SharePoint development is full of gotchas!


                      • [...] So to overcome this issue by removing the alternate header using powershell, we can use Pete’s post here, [...]

                        (Required, will not be published)

                      • cosmical