4

我想在我的 SharePoint 12 hive/template/layouts/TelephoneBookList/test.aspx 文件中使用母版文件(如果有意义,则为该网站的文件)。但是,每当我将 MasterPageFile="~/_layouts/simple.master" 或类似内容添加到我的 test.aspx 页面时,我都会在日志文件中看到一个共享点错误页面和以下内容:

2009 年 1 月 12 日 10:56:26.95 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services 拓扑 0 严重 URL 无效:http://localhost。您可能还需要更新引用http://mcdevsp的任何备用访问映射。有关此错误的帮助:http: //go.microsoft.com/fwlink/ ?LinkId=114854

2009 年 1 月 12 日 10:56:27.09 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services 常规 8dzz 高异常类型:System.Web.HttpException 异常消息:文件 '/_layouts/TelephonebookList/~masterurl/default.master' 确实不存在。

2009 年 1 月 12 日 10:56:27.23 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services 拓扑 0 严重 无效 URL:http://localhost。您可能还需要更新引用http://mcdevsp的任何备用访问映射。有关此错误的帮助:http: //go.microsoft.com/fwlink/ ?LinkId=114854

01/12/2009 10:56:27.70 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services 常规 8dzw 中 spHttpHandler:GetHash 已启动

01/12/2009 10:56:27.70 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services 常规 8dzx 中 spHttpHandler:GetHash 完成

如果没有 MasterPageFile 属性,它可以完美运行,但是它没有网站的全局外观。

非常感谢。

4

2 回答 2

4

尝试这个:

将 MasterPageFile 声明保留为默认值 (~/_layouts/simple.master) 并在您的自定义代码中覆盖 OnPreInit。

protected override void OnPreInit(EventArgs e)
{
    base.OnPreInit(e);

    this.MasterPageFile = SPContext.Current.Web.MasterUrl;
}
于 2009-01-12T14:04:17.340 回答
1

SharePoint 要求使用 ~/_layouts/application.master 声明 _layouts 页面。然后可以使用 OnPreInit 技术在运行时更改主控。

可使用 HttpModule 更改所有应用程序页面上的主文件:如何自定义 SharePoint application.master 文件

于 2009-01-12T17:45:03.213 回答