SharePoint 2010–Application Page for Anonymous Access

Recently I was working on a smart 404 page with a redirect handler so that custom urls could be handled through a SharePoint list with RegEx.  For example http://domain.com/vanity1 would see the “.com/vanity1”, and look it up on the SharePoint list to redirect the client to the appropriate URL.

The site itself was set to anonymous, however some of the solution files were placed in the /_layouts/RedirectHandler directory and I kept getting a “401 Unauthorized” message when accessing the vanity urls (despite having the _layouts/RedirectHandler in the web.config like this:

  <location path="_layouts/RedirectHandler">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>

Turns out that even though the site is anonymous, the key here is that you cannot use the default LayoutsPageBase class for the page because it would trigger SharePoint to prompt anonymous users to log on.  For example, the %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS\login.aspx page that ships with Microsoft SharePoint Foundation 2010 inherits from an internal class named LoginPage, which itself inherits from UnsecuredLayoutsPageBase.

Instead, you need to use another class for your anonymous application page called UnsecuredLayoutsPageBase. You can find its MSDN reference at: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.unsecuredlayoutspagebase.aspx

Your page class would look like this, and now everything works quite nicely without prompting anonymous users to login.

public partial class Handler : UnsecuredLayoutsPageBase
{
    protected override void OnPreRender(EventArgs e)
    {
    }
}



	

SharePoint 2010 Folder Design Best Practices

This is probably one of the biggest banes of a SharePoint Admin’s existence – Folder structure.  It’s important to really lay out a structure that makes sense and is flexible enough for the future.  There are several design considerations when using SharePoint 2010 folders when designing the information architecture.

  1. Importantly and obviously, plan for the number of items that will be organized in each folder. Those items can be moved either manually or it can be automated.
  2. Incorporate features to include the metadata navigation so that the amounts of items in folders don’t have such strict limits.
  3. Use metadata navigation and folder navigation so that the folders are able to be used for policies and retention. This is in addition to the folders being used for organization. Organization of content in folders so that they can be easily navigated as well as combined with other available options for the simplification of navigation.
  4. The content organizer will automatically move the documents into folders base on the metadata. They can also be enabled with the option for creating various sub folders after the limit in a given folder has been reached.
  5. Organize items into folder so that only the list view threshold at the root of the folder is there when you use the Open with Explorer. In order to retrieve content in list views there is metadata navigation and indexing that you can use in addition to the folders.

Organizing the content into folders needs to be done carefully. There are three main methods used for achieving this:

Organize logically – This can be based on month, year, or other types of data like responsible division. Or other stuff. Whatever’s clever.
Metadata – this allows for documents to be routed to the correct folder. This allows for the ability to limit the amount of items in a single folder. Then sub folders are also used when more space needs to be added.
Topic or category – Many users like the idea of being able to find things by topic or category. They are used to such navigation so it seems natural. This is sort of like the first point.

Various improvements for SharePoint Server 2010 allow you to have a flexible use of the folders. You will be less dependent on various performance considerations as well. When you have managed metadata and navigation you can easily filter the data through the folders. This makes it possible for you to organize your information for administrative control. This includes your permissions and policies. You won’t be relying only on the end user navigation.

When the content organizer feature is automatically moved into the folders by content, the metadata users don’t need to decide where to place the content. The content organizer also allows for the creation of new folders after a limit of one has been reached. When you use “Open with Explorer” you have to remember that it doesn’t work with large lists of items if they aren’t organized in folders with fewer items than the list view threshold.

When it comes to folder based view and metadata based views, keep in mind that they are very similar when it comes to how they perform. With a logical user experience then it is sensible to rely on folders to divide your content. With metadata navigation though there are queries that allow for all of the items to be returned outside of the folders.

* Folders do have better performance at smaller sizes of lists.*

SharePoint – How To Hide Recycle Bin & View All Site Content links in SharePoint 2010 and 2007

Sometimes more functionality is confusing to the end user.  While I think these are good features to have, just like with the article from last month : http://iedaddy.com/2010/02/how-to-hide-left-display-panel-in-sharepoint-2010/ the owner wants the site to “look less sharepointy”.  And so here’s how to remove the Recycle bin from your pages as well:

The easiest way is to use the old school CEWP trick that worked even back in 2003, just add a the Web Part that now has the name Content Editor and add the following text in the HTML Source mode:

In a 2007 site:

<style type="text/css">
.ms-quicklaunchheader{display: none;}
.ms-recyclebin{display: none;} 
</style>

In a SharePoint 2010 Site:

<style type="text/css">

/* To Hide both */
.s4-specialNavLinkList{display:none;}

/* To Hide "Recycle bin" */
.s4-rcycl{display:none;} 

/* To Hide "All Site Content" */
#ctl00_PlaceHolderLeftNavBar_PlaceHolderQuickLaunchBottom_PlaceHolderQuickLaunchBottomV4_idNavLinkViewAllV4{display:none;}

</style>