Пример #1
0
        /// <summary>
        /// Administra la autorización por Request
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AuthorizeRequest(object sender, EventArgs e)
        {
            var lt = new List <String>()
            {
                "/Account/", "/Images/", "/Scripts/", ".axd", ".ashx", ".css", ".asmx"
            };

            if (((IObjCache)System.Web.HttpContext.Current.Cache.Get("Lpg")) == null)
            {
                List <IPagePTO> pg = new List <IPagePTO>();
                pg.Add(Usr.LPage());
                UsrCache.AddPagesToCache("Lpg", new ObjCache(pg, null), HttpContext.Current);
            }
            if (lt.Any(r => HttpContext.Current.Request.Path.ToLower().Contains(r.ToLower())))
            {
                return;
            }
            //if (HttpContext.Current.Request.Path.ToLower().Contains("/account/"))
            //{
            //    return;
            //}
            if (HttpContext.Current.User != null)
            {
                //Si el usuario esta Autenticado
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    if (HttpContext.Current.User is FPrincipal)
                    {
                        FPrincipal principal = (FPrincipal)HttpContext.Current.User;
                        if (!principal.IsPageEnabled(HttpContext.Current.Request.Path))
                        {
                            HttpContext.Current.Server.Transfer("~/Account/AuthE.aspx");
                        }
                    }
                }
            }
        }