Today I thought about how to put the masterpage of a web behind a custom application page. Just try to add the navigation elements on you custom application page and you know why.
Just changing the page directive of the application page does not solve the problem, because SharePoint tries to build a relative path. After searching the web, I found the solution for this problem in the comments of a blog entry of Serge van den Oever. The comment of Carsten Keutmann shows the trick:
protected override void OnPreInit(EventArgs e)
this.MasterPageFile = SPContext.Current.Web.MasterUrl;
It seems, as if this is a really simple solution.