protected override void LookForNewUrl(HttpContext context, string requestedUrl)
        {
            base.LookForNewUrl(context, requestedUrl);

            if (IsUserLogged)
            {
                string query = context.Request.Url.Query.Replace("?", "");

                using (CompanyManager manager = new CompanyManager(null))
                {
                    Company company = manager.GetCompanyByContext(Context);
                    if (company != null)
                    {
                        string newUrl;

                        //
                        // Try the company website
                        //
                        string webSite = ("" + company.LegalEntityProfile.Website).ToLower().Replace("http://", "").Replace("www.", "");
                        if (!String.IsNullOrEmpty(webSite) && !requestedUrl.Contains(webSite.ToLower()))
                        {
                            newUrl = "~/infocontrol/_companies/" + webSite + "/" + requestedUrl.ToLower().Replace("infocontrol/", "");

                            // rewrite the path..
                            if (newUrl != requestedUrl && System.IO.File.Exists(Context.Server.MapPath(newUrl)))
                            {
                                RewritePath(newUrl, String.Empty, query);
                                return;
                            }
                        }
                    }
                }
            }
        }
        public override InfoControl.Web.Auditing.Event LogErrorInDatabase(Exception ex)
        {

            var eventEntity = base.LogErrorInDatabase(ex);
            HttpContext context = HttpContext.Current;

            if (context != null && context.Session != null)
                using (var customerManager = new CustomerManager(null))
                using (var companyManager = new CompanyManager(null))
                using (var membershipManager = new MembershipManager(null))
                {
                    Company hostCompany = companyManager.GetHostCompany();
                    Company company = companyManager.GetCompanyByContext(context);

                    Customer customer = customerManager.GetCustomerByLegalEntityProfile(hostCompany.CompanyId, company.LegalEntityProfileId);

                    if (customer != null)
                    {
                        var customerCall = new CustomerCall();
                        customerCall.EventId = eventEntity.EventId;

                        customerCall.Subject = (ex.Message.Length > 100 ? ex.Message.Substring(0, 90) + " ..." : ex.Message);

                        customerCall.CallNumber = Util.GenerateUniqueID();
                        customerCall.CompanyId = hostCompany.CompanyId;
                        customerCall.CustomerId = customer.CustomerId;
                        customerCall.OpenedDate = customerCall.ModifiedDate = DateTime.Now.Date;
                        customerCall.Description = String.Empty;

                        customerCall.CustomerCallTypeId = CustomerCallType.ERROR;
                        customerCall.CustomerCallStatusId = CustomerCallStatus.New;
                        customerCall.Rating = 5;

                        customerCall.CallNumberAssociated = context.Request.RawUrl;
                        customerCall.Sector = Convert.ToString(context.Session["_lastPageTitle"]);

                        if (context.User != null)
                            if (context.User.Identity != null)
                                if (context.User.Identity.IsAuthenticated)
                                {
                                    User user = membershipManager.GetUserByEmail(context.User.Identity.Name);
                                    if (user != null)
                                        customerCall.UserId = user.UserId;
                                }

                        customerManager.InsertCustomerCall(customerCall, null, null, null);
                    }
                }
            return eventEntity;
        }