Running a SharePoint App From Your Own Copy of the Layouts Folder

Did you ever want to tinker with some of the ASPX pages in the layouts folder of the SharePoint hive? You might want to customize the appearance of application.master, for example. Or, you might want to diverge from the released _layouts pages so that some web apps use your customized versions. When Microsoft releases patches, they’ll be installed in the hive, thereby giving you the chance to run a diff to see what you need to migrate into your copied folder. With sufficient permissions, you can edit the layouts pages directly of course, but it’d be safer to work with your own private copy until you know your changes are safe to be unleashed on an unsuspecting populous. Here’s how to point a web app at your local copy of the layouts folder.

  1. Make your own copy of the layouts folder

    SharePoint’s _layouts pages are at this oh-so-easy-to-remember location: C:\Program Files\Common Files\Microsoft Shared\Web Server Extension\12\template\layouts. Copy this folder and paste it wherever you want if you’re just hacking around. If you plan to run a production web app from your copy of layouts, a good place to put the copy might be C:\Inetpub\wwwroot\webapps\your_web_app\layouts. You might have to adjust the file system permissions on the folder containing your layouts copy — whichever user your web app runs as (typically ASPNET) will need Read access.

  2. Point your web app at your copy

    Open IIS Manager, navigate to your web app, and expand the tree so that you can see the _layouts folder; it will look like the figure below.

    IIS_layouts_1

    Right-click the _layouts folder, and select Properties from the context menu. On the Virtual Directory tab, select the radio button indicating that the content should come from “A directory on this computer” and in the Local path field, enter the full path to the location of your copy of the layouts folder. Make sure the box for Read access is checked, and check any others that pertain. Then click OK.

    IIS_layouts_2

  3. Run the iisreset command.

Your app will now use the files in your copy of layouts for all of SharePoint’s _layouts pages.

Advertisements
Tagged with:
Posted in SharePoint
5 comments on “Running a SharePoint App From Your Own Copy of the Layouts Folder
  1. […] usually unsafe, as a hotfix might clobber your changes.  (My partner Pete Sterpe just published a blog post about one way to manage this, if you need to do it.)  Generally speaking, anything in the file […]

  2. Math says:

    Hi,
    Nice post.
    How do you manage solution deployment which copy some files or folder in the layouts folder?
    I applied your post but when I try to deploy solutions, files are not copied in the copied layouts.

    Any idea?
    Thx. Math

    • psterpe says:

      Math, I’m not quite understanding the use case you’re describing. Could you tell me more about what you’re doing and what’s going wrong?

      • Math says:

        I have a SharePoint solution (wsp) which adds new application pages to the layouts folder.
        After deploying the wsp, these pages are available on the usual layouts folder for other web apps. But for the one using my own copy of the layouts folder, pages are not. Looking at the folder, pages were not deployed.

        I assume that this is because the layouts folder mapped in my Visual Studio project can only be the usual one (in 12 hive).

        Any idea on how to overcome this?
        Thank you for your help.

      • psterpe says:

        Math, I’m checking with a friend who is more knowledgeable and more current — I haven’t worked with SharePoint for quite a while! I was advocating a technique for development, not for production use. I’m not sure what you’re trying is a good idea. By the way, check out my friend’s blog — it’s FULL of great SharePoint knowledge. See http://sympmarc.com/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: