SharePoint Custom Application Pages and Custom Action Features: did you know this?

At the moment I am reading Inside Microsoft Windows SharePoint Services 3.0 to prepare for the Microsoft Certified Master SharePoint program. I consider myself an experienced SharePoint developer, but I came across a couple of basic facts that I didn't know or wasn't fully aware of.

  • The first tip: when you are creating custom Application Pages for SharePoint 2007 (WSS and MOSS alike) your page should inherit from Microsoft.SharePoint.WebControls.LayoutsPageBase. I never realized that there was a separate class an application page should inherit from. Mine always just inherit from System.Web.UI.Page. While looking up the LayoutsPageBase on MSDN I came across some more information. When creating a custom application page that is intended for use by authorized users you should use LayoutsPageBase. If your application page will be used by anonymous users you should use UnsecuredLayoutsPageBase.
  • The second tip: when creating a custom action feature you can use ~site and ~sitecollection to create site or site collection relative urls. If you are creating a custom action that adds a link to the ECB menu of a list or library item you can also use {ItemId}, {ItemUrl} and {ListId} to get the itemid and listid of the currect item. If you read the "How to: Add Actions to the User Interface" page on MSDN you notice that you can also use {SiteUrl}.

Example:
<!-- Per Item Dropdown (ECB)-->
  <CustomAction
    Id="UserInterfaceCustomActions.ECBItemToolbar"
    RegistrationType="List"
    RegistrationId="101"
    Location="EditControlBlock"
    Sequence="106"
    Title="MY ECB ITEM">
    <UrlAction Url="~site/_layouts/CustomActionsHello.aspx?ItemId={ItemId}&amp;ItemUrl={ItemUrl}&amp;ListId={ListId}"/>
  </CustomAction>

Perhaps you were already aware of these tips, but since I wasn't I thought I should share them.