2014-01-08 75 views
2

我希望这是提问的正确位置。我试过使用sosial msdn,但似乎msdn论坛已经死了。主页有小问题。我已经创建了Web模板和主页面。当我创建新的网站集并尝试访问它时(http://win2008r2/sites/Test),它会引发错误:“404 NOT FOUND”。SharePoint Foundation 2013 - Master Page 404 NOT FOUND

然而,当我检查母版图库:http://win2008r2/sites/Test/_catalogs/masterpage/Forms/AllItems.aspx

我能找到我Demo.master。当我检查网站集功能时,我可以看到我的主页功能处于活动状态。我检查了日志,这只是我发现的东西:获取文档时失败。 0x80070002

我已经设置Web模板范围农场。我将母版页范围网站

我试图解决问题,使用谷歌,我试过不同的指南,但没有我不能得到它的工作。谁能帮帮我吗?

这里是Element.xml:

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

这里是事件接收器:

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(); 
     } 

如果你想看到更多的我的代码来解决这个问题,请随时问,这样我放了更多的代码。 ;)

+0

ONet.xml文件,我添加我的母版页: user3172297

+0

在这一点上,我不再有任何想法来解决这个问题。所以如果有人知道至少有什么,那么比没有好。 – user3172297

+0

不要从SPSite.RootWeb中部署SPWeb对象。 – trgraglia

回答

0

谢谢Yevgeniy.Chernobrivets!问题是我已经将我的default.aspx命名为MySite.aspx,并且它不起作用。当我再次创建它,并保持default.aspx名称的工作!那么现在我必须找到方法来改变该default.aspx名称=)