简体   繁体   中英

SharePoint Foundation 2013 - Master Page 404 NOT FOUND

I hope this is right place to ask question. I tried use sosial msdn, but it seems that msdn forum is dead. I have small problem with Master Page. I have created Web Template and Master Page. When I create new site collection and I try access to it ( http://win2008r2/sites/Test ), it throws me error that: "404 NOT FOUND".

However, when I check MasterPage gallery: http://win2008r2/sites/Test/_catalogs/masterpage/Forms/AllItems.aspx

I can find my Demo.master . When I check Site Collection Features, I can see that my Master Page feature is active. I checked the logs and this was only thing what I found: Failure when fetching document. 0x80070002

I have set Web Template scope to farm and I have set Master Page scope to site .

I try to solve problem using google and I tried different guides but no I cannot get it work. Can anyone please help me?

Here is Element.xml:

<Module Name="MyMasterPage" List="116" Url="_catalogs/masterpage">
    <File Path="MyMasterPage\Demo.master" Url="Demo.master" Type="GhostableInLibrary">
    </File>
  </Module>

Here is event receiver:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                using (SPWeb _web = ((SPSite)properties.Feature.Parent).RootWeb)
                {
                    Uri _siteMaster = new Uri(string.Format("{0}/_catalogs/masterpage/Demo.master", _web.Url));
                    _web.MasterUrl = _siteMaster.AbsolutePath;
                    _web.CustomMasterUrl = _siteMaster.AbsolutePath;
                    _web.Update();
                }
            });
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPSite curSite = (SPSite)properties.Feature.Parent;
            SPWeb curWeb = curSite.RootWeb;
            Uri masterUri = new Uri(curWeb.Url + "/_catalogs/masterpage/v4.master");
            curWeb.MasterUrl = masterUri.AbsolutePath;
            curWeb.CustomMasterUrl = masterUri.AbsolutePath;
            curWeb.Update();
        }

If you want to see more of my code to solve this problem, please feel free to ask, so I put more code up. ;)

Thank you Yevgeniy.Chernobrivets! Problem was that I had named my default.aspx to MySite.aspx and it didn't work. When I created it again and I keep default.aspx name it worked! Well now I have to find way to change that default.aspx name =)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM