Note: Click the links above to view details and source code about the components, user controls, and stored procedures used to create this page.
Description and Features: The Default.aspx page is the home page for the Adventure Works Cycles application. It welcomes users to the application and provides a short overview. To entice users into entering deeper into the site, the default page displays a weekly "most popular items" list and a single featured item displayed with a graphic.
Implementation Details: The default page is largely static - much of the work is done by other components. For example, the header, menu, and "popular items" list are all implemented in separate user controls referenced from this page.
The default page itself includes just a few lines of code to check whether the user has logged in. If so, the page displays a friendly personalized welcome message. The personalization is done in the Page_Load event-handling method. This event is raised on the server every time the page is accessed by a browser. It provides a convenient way to structure server logic that needs to run at the beginning of every page access. The code looks like this:
void Page_Load(Object sender, EventArgs e) { // Customize welcome message if personalization cookie is present if (Request.Cookies["AdventureWorks_FullName"] != null) { WelcomeMsg.Text = "Welcome " + Request.Cookies["AdventureWorks_FullName"].Value; } }
In the method, the welcome message is generated by retrieving a client-side cookie (persisted on the client in the Login.aspx and Register.aspx pages). If the cookie is found, the user name is extracted from it and displayed using a server-side label control. For details about how the cookie is generated, review the Login.aspx page.
Performance Notes