我希望这是提出问题的正确位置。我试过使用sosial msdn,但似乎msdn论坛已经死了。我对Master Page有小问题。我创建了Web模板和母版页。当我创建新的网站集并尝试访问它(http://win2008r2/sites/Test
)时,它会抛出错误:“404 NOT FOUND”。
但是,当我查看MasterPage图库时:http://win2008r2/sites/Test/_catalogs/masterpage/Forms/AllItems.aspx
我可以找到我的Demo.master。当我检查网站集功能时,我可以看到我的母版页功能处于活动状态。我检查了日志,这只是我发现的东西:获取文件时失败。 0x80070002
我已将网络模板范围设置为场,并且我已将母版页范围设置为网站。
我尝试使用谷歌解决问题,我尝试了不同的指南,但没有我不能让它工作。有人可以帮帮我吗?
这是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 :(得分:0)
谢谢Yevgeniy.Chernobrivets!问题是我将default.aspx命名为MySite.aspx并且它不起作用。当我再次创建它并保持default.aspx名称它工作!那么现在我必须找到改变default.aspx name =)
的方法