protected void Application_Error(object sender, EventArgs e) { Exception Ex = Server.GetLastError().GetBaseException(); Server.ClearError(); ActionLogs.LogExceptionError(Context.User.Identity.Name, Ex, System.Web.HttpContext.Current.Request.Url.ToString()); string dbRole = ""; SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["FileDatabaseConnectionString2"].ConnectionString); connection.Open(); SqlCommand myCommand = new SqlCommand("SELECT Role FROM UserAccount WHERE Username = @AccountUsername", connection); myCommand.Parameters.AddWithValue("@AccountUsername", Context.User.Identity.Name); SqlDataReader myReader = myCommand.ExecuteReader(); while (myReader.Read()) { dbRole = (myReader["Role"].ToString()); } connection.Close(); if (dbRole.Equals("Boss")) { Response.Redirect("~/Content/BossConsole/ErrorPages/Error.aspx"); // Server.Transfer("~/Content/BossConsole/ErrorPages/Error.aspx"); } else { Response.Redirect("~/Content/StaffConsole/ErrorPages/Error.aspx"); // Server.Transfer("~/Content/StaffConsole/ErrorPages/Error.aspx"); } }