The application page (also known as the _ layouts page) is stored in the C:/program files/common files/Microsoft shared/Web Server Extensions/12/template/layouts directory. The corresponding virtual directory in IIS is: _ layouts.
The application page uses the application. master page and inherits from Microsoft. Sharepoint. webcontrols. layoutspagebase. Only authorized users can access this page.
A simple application page is shown below:
- <% @ Assembly name = "Microsoft. Sharepoint, version = 12.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c" %>
- <% @ Page Language = "C #" masterpagefile = "~ /_ Layouts/application. Master"
- Inherits = "Microsoft. Sharepoint. webcontrols. layoutspagebase" %>
- <% @ Import namespace = "Microsoft. SharePoint" %>
- <SCRIPT runat = "server">
- Protected override void onload (eventargs E)
- {
- Spweb web = spcontext. Current. Web;
- Spuser currentuser = web. currentuser;
- Lblusername. Text = currentuser. Name;
- Lbluserlogin. Text = currentuser. loginname;
- Lbluseremail. Text = currentuser. Email;
- }
- </SCRIPT>
- <Asp: Content ID = "Main" contentplaceholderid = "placeholdermain" runat = "server">
- <Table border = "1" cellpadding = "4" cellspacing = "0" style = "font-size: 12">
- <Tr>
- <TD> currentusername: </TD>
- <TD> <asp: Label id = "lblusername" runat = "server"/> </TD>
- </Tr>
- <Tr>
- <TD> currentuserlogin: </TD>
- <TD> <asp: Label id = "lbluserlogin" runat = "server"/> </TD>
- </Tr>
- <Tr>
- <TD> currentuseremail: </TD>
- <TD> <asp: Label id = "lbluseremail" runat = "server"/> </TD>
- </Tr>
- </Table>
- </ASP: content>
- <Asp: Content ID = "pagetitle" runat = "server"
- Contentplaceholderid = "placeholderpagetitle">
- Hello World
- </ASP: content>
- <Asp: Content ID = "pagetitleintitlearea" runat = "server"
- Contentplaceholderid = "placeholderpagetitleintitlearea">
- The quintessential 'Hello world' application page
- </ASP: content>
In addition, the page under _ layout does not inherit the SharePoint class,
For example:
- <% @ Page Language = "C #" %>
- <% @ Assembly name = "Microsoft. Sharepoint, version = 12.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c" %>
- <% @ Import namespace = "Microsoft. SharePoint" %>
- <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <SCRIPT runat = "server">
- Protected override void onload (eventargs E)
- {
- Spweb web = spcontext. Current. Web;
- Spuser currentuser = web. currentuser;
- Lblusername. Text = currentuser. Name;
- Lbluserlogin. Text = currentuser. loginname;
- Lbluseremail. Text = currentuser. Email;
- }
- </SCRIPT>
- <HTML xmlns = "http://www.w3.org/1999/xhtml">
- <Head runat = "server">
- <Title> No title page </title>
- </Head>
- <Body>
- <Form ID = "form1" runat = "server">
- <Div>
- <Table border = "1" cellpadding = "4" cellspacing = "0" style = "font-size: 12">
- <Tr>
- <TD> currentusername: </TD>
- <TD> <asp: Label id = "lblusername" runat = "server"/> </TD>
- </Tr>
- <Tr>
- <TD> currentuserlogin: </TD>
- <TD> <asp: Label id = "lbluserlogin" runat = "server"/> </TD>
- </Tr>
- <Tr>
- <TD> currentuseremail: </TD>
- <TD> <asp: Label id = "lbluseremail" runat = "server"/> </TD>
- </Tr>
- </Table>
- </Div>
- </Form>
- </Body>
- </Html>