Click here to Skip to main content
15,888,340 members
Articles / Web Development / XHTML

Fully configured ASP.NET Membership Website Template

Rate me:
Please Sign up or sign in to vote.
4.89/5 (18 votes)
7 Jul 2009CPOL4 min read 165.2K   8.3K   119  
A pre-configured ASP.NET website containing a Master page, error handling, login / logout, and other boilerplate new project code.
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Web.Security;

/// <summary>
/// Summary description for BasePage
/// </summary>
public class BasePage : System.Web.UI.Page
{
    #region Public Methods

    public void HandleException(Exception ex)
    {
        if (ConfigurationManager.AppSettings["Environment"] == "Development")
        {
            Master.ErrorMessage = ex.Message;
        }
        else
        {
            Master.ErrorMessage = "An unexpected error has occured in the application.  If it continues, please contact the administrator.";
        }
        // TODO Log the exception somehow, either with Microsoft.Practices.EnterpriseLibrary.Logging or some other mechanism
    }

    #endregion

    #region Public Properties

    public MembershipUser CurrentUser
    {
        get { return Session["CurrentUser"] as MembershipUser; }
        set { Session["CurrentUser"] = value; }
    }

    public new BaseMasterPage Master { get { return (BaseMasterPage)base.Master; } }

    public string ErrorMessage
    {
        set { Master.ErrorMessage = value; }
    }

    public string InformationMessage
    {
        set { Master.InformationMessage = value; }
    }

    public string WarningMessage
    {
        set { Master.WarningMessage = value; }
    }

    #endregion
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Harland Financial Solutions
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions