SharePoint 2007, ** CAUTION ** Editing Application.Master (or any _layouts files)

This post is simply to avoid the invetiable.  As time goes on more and more people will attempt edits of their application.master page as well as other pages within the _layouts directory.

Before you do be make sure you fully understand the possibile consequences, some important things to realize are listed below:

1) Microsoft does not support editing default (file system) pages, they can easily be overwritten during updates, patches etc.  Please make sure everyone (This includes management, developers, customers – everyone) is aware of this.

2) SharePoint Designer 2007 can and does make automatic changes to page tokens and references which can break pages within your _layouts folder.  In the event that you find yourself starting at an error after editing your application.master page in SPD, now you know why.  Check the page changes (at the top of the page).

For those that have no fear and realize the potential threats editing these pages cause, please make sure you have a VERY solid back-up story and that it’s followed.

This post was mostly to point out the fact that SharePoint Designer 2007 does make automatic changes to pages without your knowledge – these changes can and do break the pages within the _layouts folder on the servers file system.  Hopefully there will be options for “no automatic” code changes, or “warn before all” in the final builds. 

25 comments on “SharePoint 2007, ** CAUTION ** Editing Application.Master (or any _layouts files)

  1. superfly says:

    Shane,

    I have not been able to find application.master in SPD 2007. Does it exist in SPD or do you modify it at the file system level in the layouts folder?

  2. shane says:

    Be very aware of the following:

    1) You should be very aware of the fact that modifying the application.master is “NOT” supported by Microsoft, as is the case for all default (out of the box) files residing on the file system.

    2) Opening/Saving ANY file in the _layouts folder using SharePoint Designer 2007 will result in page/token changes which will cause the page to stop functioning, and to display an error.

    3) You are correct in thinking that it’s located in the _layouts folder of the file system.

  3. superfly says:

    I hope Microsoft corrects this. I am running into an issue where one server has sites with unique branding. This is a bummer.

  4. Andrew Woods says:

    I modified the application.master in the _layouts folder and now my _layouts pages are broken, as in there is an ‘unknown error’ when I try to access certain areas such as Site Settings, or Create. I have no idea how to reset the application.master back to its default state in order to get things working again… Any help would be greatly appreciated.

    I know how stupid it was not to backup the file before I did this.

  5. shane says:

    Andrew,

    There is a pretty good chance you may be removed a placeholder which another page is trying to use. (or if you edited in SharePoint Designer, it’s likely a change was made to the page tokens)

    Your best options are:

    1) The obvious – learn from this mistake, and never make file-system changes without backing up.
    2) Turn on friendly error messages so that you have a better chance at troubleshooting: http://www.graphicalwonder.com/?p=648
    3) If all else fails, grab a clean (MOSS 2007) application.master, and overwrite your old.

  6. Josh says:

    ok the layouts directory from the application.master file was remapped into a personal site created. Now everytime you import a spreadsheet for a custom list, it gives an error “This Virtual Directory does not allow contents to be listed.” Was there a change in the page tokens? Any help would be great

  7. Chris says:

    I have made changes to the class that makes the welcome menus now WHITE instead of BLACK (or gray?) the way they are by default. By doing this, you obviously change them in the admin too. But the admin section uses “Application.master”.. in which if you change that file, very bad things happen, according to the above comments.

    AND, furthermore, you cannot override (as far as I’ve been able to) the inner style class constructed on the fly.

    Take for example the following server control

    This generates the ever so loved Welcome COMPANYNAMEAdministrator.

    This wonderful little server control generates its own DIV around itself with the class of class=”ms-SPLink ms-SpLinkButtonInActive”
    And guess what? Modifying either of those modifies it everywhere. Even if you !important previous classes, you simply cannot (that I’ve found) get inside of this thing.

    Can anyone think of a way to do this properly and carefully?

  8. Luke Evans says:

    Hi,

    I am currently customizing a site. I have completed the customization from ‘default.master’ and all the pages pointing to ‘default.master’ for the layout are working fine.

    But if you go to a page like ‘View All Site Content’ (http://mysharepointsite/_layouts/viewlsts.aspx) or ‘Site Settings’, these pages seem to be referencing a different master page for their layout.

    Where can I find this ‘master page’ to fix the layout?? My _layouts folder is not visible in SPD.

    Looks like this could be a touchy/dangerous subject, from reading other post on this thread…

    Any thoughts or direction??

    Thanks.

  9. Alex Pearce says:

    Hi,
    Josh – did you find how to fix your problem as i have the same as well.

    Thanks

    Alex

  10. Zach says:

    I found that as long as I modified my application.master within Visual Studio 2005, everything worked okay. But, if I used SharePoint Designer 2007, it hosed the site.

  11. Jason says:

    Ok, so I’m an idiot and modified this file (in SPD) BEFORE reading all these lovely warnings online that I shouldn’t. Of course now I’m getting errors. The log contains:

    Exception Type: System.Web.HttpException Exception Message: The file ‘/_layouts/_controltemplates/TopNavBar.ascx’ does not exist.

    This file does exist in C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATELAYOUTS

    I restored the file contents from the backup I made before monkeying with it (just a Notepad copy/paste) but it looks like my tokens are messed up now in WSS. Any suggestions on how I can check/repair them?

  12. Hi, I ran into this same problem. SharePoint Designer changes the src on the registered controls for the page by removing ~/. This was an issue I ran into with application.master.

    It changes to:

    It should be what is below, notice SharePoint Designer removed the ~/ on the src attribute above:

  13. Magnus says:

    I seem to have opened the application.master and the createpage.aspx in SPD.

    i now try to access the createpage.aspx page and get:

    The file ‘/_layouts/_layouts/application.master’ does not exist. at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
    at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
    at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
    at System.Web.UI.BaseTemplateParser.GetReferencedType(VirtualPath virtualPath, Boolean allowNoCompile)
    at System.Web.UI.PageParser.ProcessMainDirectiveAttribute(String deviceName, String name, String value, IDictionary parseData)
    at System.Web.UI.TemplateParser.ProcessMainDirective(IDictionary mainDirective)

    can anyone help out?

  14. Magnus says:

    I add the ~ in the createpage.aspx file since it was missing, but then I get:

    The server tag is not well formed. at System.Web.UI.TemplateParser.ProcessError(String message)
    at System.Web.UI.TemplateParser.DetectSpecialServerTagError(String text, Int32 textPos)
    at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
    at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)

  15. Magnus says:

    OK. so i just replaced the Createpage.aspx with an old one.

    Now it works again. Damn the Sharepoint Designer!

  16. shane perran says:

    Opening your application.master in SPD changes some code at the top of the page. You can either add the ~/ back to your registered controls or you can grab a fresh application.master – from a different install.

    Shane

  17. Magnus says:

    Ok, thanks.

    I am trying to narrow down the page layout options for the user on the CreatePage.aspx page. So I was thinking I should edit this page.

    Then, even the slightest modification in this CreatePage.aspx file (just adding a simple linebreak wherever) gives me this error:

    The server tag is not well formed. at System.Web.UI.TemplateParser.ProcessError(String message)
    at System.Web.UI.TemplateParser.DetectSpecialServerTagError(String text, Int32 textPos)
    at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
    at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)

    Why?? Because I am using Wordpad instead of SPD?

  18. Scott says:

    So, this is fun. I too opened the application.master page before reading that opening it in SPD would send the globe sprialing out of orbit.

    I thought, no big deal I’ll replace it with the backup I have. Replacing the backup DID NOT WORK, and I KNOW that it was a clean backup because I didnt touch it! :P So after reading here I went and got a “clean” copy of the file and replaced it with that. Now, when trying to view, for example, the /_layouts/viewlsts.aspx page I get a HTTP 403 Forbidden error.

    I looked into the permissions, and I mean, obviously no permissions changed but its telling me that somehow, some way, they did. I’m really very stuck at what even to check next.

    Anyone have any advice on what else I can look in to to solve this mess?

    Thanks!
    Also, thanks for writing up the warning so other people can find it, its greatly appriciated. It helps a lot to be able to find this kind of information. =)

    Scott

  19. Paul says:

    I used the information at this site, Andrew Connell and Heathers too, and I’ve written 5 articles and I’m currently working on part 6 of an epic SharePoint branding series. The deeper I dig the more articles it requires. Anyway, I went through 6 non nasty methods of dealing with this application.master and core.css.

    http://www.cleverworkarounds.com/2007/10/08/sharepoint-branding-how-css-works-with-master-pages-part-1

    Hope its of help to some..

  20. Brian Carnes says:

    Microsoft posted an article on this subject yesterday. How to customize application pages in the Layouts folder in SharePoint Server 2007 and in Windows SharePoint Services 3.0: http://support.microsoft.com/kb/944105

  21. yugandhar says:

    Hi,

    I am currently customizing a site. I have completed the customization from ‘default.master’ and all the pages pointing to ‘default.master’ for the layout are working fine.

    But if you go to a page in a sub site or top site and open a custom list page, open an item to view or edit the page, it is redirecting to its corresponding pasis having the same master page what i mentioned but the font size is so small that i can’t even read.I didn’t changed any thing in core.css, for any modification for style in master page i created a different style sheet – mystyle.css and i’m using it for background colors. This problem is every where in the site view or edit item page.I’m having 33 subsites in a top level site and all are facing this problem.Can any one of you help me in this.This is an urgent problem.

    Thanks.

  22. Stephen Kaye says:

    I’ve developed a solution that allows the site admin to specify an alternate to using the application.master per web.

    http://stephenkaye.blogspot.com/2008/03/how-to-customise-applicationmaster-file.html

  23. Rob Monti says:

    Well, I too forged ahead without heeding the warnings, and now I’m paying for it. I backed up the application.master file, but unfortunately I made the mistake of attempting to edit it in SPD.

    I’m positively ill at this point.

    Anybody know where I can get a clean application.master file?

Leave a Reply