How to use the site’s homepage on the _layout SharePoint page?

I want to use the masterpage file (site one, if that makes sense) in my hiv / template / layouts / 12 / v template. However, when I add MasterPageFile = "~ / _layouts / simple.master" or something like that to my test.aspx page, I get a sharepoint error page and the following in the log file:

12/01/2009 10: 56: 26.95 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services Topology 0 Critical Invalid URL: http: // localhost . You may also need to update any alternative access mappings that reference http: // mcdevsp . Help for this error: http://go.microsoft.com/fwlink/?LinkId=114854

12/01/2009 10: 56: 27.09 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services General 8dzz High Exception Type: System.Web.HttpException Exception message: file / _layouts / TelephonebookList / ~ masterurl / default. master "does not exist.

12/01/2009 10: 56: 27.23 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services Topology 0 Critical Invalid URL: http: // localhost . You may also need to update any alternative access mappings that reference http: // mcdevsp . Help for this error: http://go.microsoft.com/fwlink/?LinkId=114854

12/01/2009 10: 56: 27.70 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services General 8dzw Medium spHttpHandler: launch GetHash

12/01/2009 10: 56: 27.70 w3wp.exe (0x1064) 0x1280 Windows SharePoint Services General 8dzx Medium spHttpHandler: GetHash completed

Without MasterPageFile attributes, it works great, however it does not have a global Look and Feel website.

Thank you very much.

+4
source share
2 answers

Try the following:

Leave the MasterPageFile declaration on it by default (~ / _layouts / simple.master) and override OnPreInit in your custom code.

protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); this.MasterPageFile = SPContext.Current.Web.MasterUrl; } 
+4
source

SharePoint requires _layouts pages to be advertised using ~ / _layouts / application.master. You can then use the OnPreInit method to modify the wizard at run time.

The HttpModule can be used to modify the wizard on all pages of the application: How to configure the application.master SharePoint file

+1
source

All Articles