using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;
//this line is necessary for the chapter code to work
using System.Security.Principal;

namespace exceptionsproject 
{
	/// <summary>
	/// Summary description for Global.
	/// </summary>
	public class Global : System.Web.HttpApplication
	{
		public Global()
		{
			InitializeComponent();
		}	
		
		protected void Application_Start(Object sender, EventArgs e)
		{

		}
 
		protected void Session_Start(Object sender, EventArgs e)
		{

		}

		protected void Application_BeginRequest(Object sender, EventArgs e)
		{

		}

		protected void Application_EndRequest(Object sender, EventArgs e)
		{

		}

		protected void Application_AuthenticateRequest(Object sender, EventArgs e)
		{
			/*
			 * this code was not included in
			 * the chapter but should have been
			 */

//			IPrincipal user = this.Context.User;
//
//			if (user != null) 
//			{
//				string[] roles = null;
//				string userName = user.Identity.Name;
//				
//				if (userName != null) 
//				{
//					if (userName == "Jose Mojica")
//						roles = new String[2] {"Admin", "User"};
//					else if (userName == "Robert Jordan")
//						roles = new String[1] {"User"};
//					else 
//						roles = new String[1] {"Guest"};
//			
//					this.Context.User = new GenericPrincipal(user.Identity, roles);
//				}
//			}
			
		}

		protected void Application_Error(Object sender, EventArgs e)
		{
			//insert code here
		}

		protected void Session_End(Object sender, EventArgs e)
		{

		}

		protected void Application_End(Object sender, EventArgs e)
		{

		}
			
		#region Web Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
		}
		#endregion
	}
}

