SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

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 have a feature receiver with the following code:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
            SPSite site = (SPSite)properties.Feature.Parent;
            SPWeb web = site.RootWeb;


and in SetContentType:

public static void SetContentType(SPWeb web)
        using (SPWeb storiesWeb = web.Webs[Constants.SiteNames.Stories])
            var stories = storiesWeb.Lists.TryGetList(Constants.ListNames.Pages);
            if (stories != null && stories.ContentTypes[Constants.ContentTypeNames.Story] == null)
                SPContentType storyContentType = web.AvailableContentTypes[Constants.ContentTypeNames.Story];
                if (storyContentType != null)
                    // Set the story content type to be the default one
                    SPContentTypeCollection currentOrder = stories.ContentTypes;
                    List<SPContentType> result = new List<SPContentType>();
                    foreach (SPContentType ct in currentOrder)
                        if (ct.Name.Contains(Constants.ContentTypeNames.Story))
                    stories.RootFolder.UniqueContentTypeOrder = result;
                        storiesWeb.AllowUnsafeUpdates = true;
                        storiesWeb.AllowUnsafeUpdates = false;

on stories.Update() I get the following error:

"Save Conflict.

Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes."

I have tried a few things with web.Update(), web.AllowUnsafeUpdates = true etc but first time I deploy I always get the same error, if I deploy it again I don't get any error. I'm sure it's something simple but I can't see it right now.

Any ideas?

Thanks in advance.

share|improve this question
up vote 0 down vote accepted

Try changing your using statement to:

using (SPWeb storiesWeb = new SPSite(site.Webs[Constants.SiteNames.Stories].Url).OpenWeb())) {...}

Also try calling update just after adding the content type. Then REFETCH the 'stories' list and do your modifications and then call update again. I've had a similar problem when updating content types via powershell which involved getting the content type each time again otherwise I'd get the save conflict issues.

share|improve this answer
thanks, refetch the list was key – John Nov 28 '12 at 22: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.