Ejemplo n.º 1
0
        public void FindRefrall(int TodayTotal)
        {
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                VisitCounter c = new VisitCounter();
                TodayTotal = TodayTotal + 1;

                c.ClientIP   = Request.UserHostAddress;
                c.VisitDate  = DateTime.Now;
                c.VisitCount = 1;
                c.TotalVisit = TodayTotal;
                if (Request.UrlReferrer != null)
                {
                    c.RefrallPage = Request.UrlReferrer.ToString();
                }
                else
                {
                    c.RefrallPage = "ورود مستقیم";
                }
                System.Web.HttpBrowserCapabilities browser = Request.Browser;
                c.Browser = browser.Type;
                c.OS      = ReturnOS();

                db.VisitCounter.Add(c);
                db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        private HtmlTextWriter getCorrectTagWriter(HtmlTextWriter writer)
        {
            if (this.Site != null && this.Site.DesignMode)
            {
                return(writer);
            }

            if (this.tagWriter != null)
            {
                return(this.tagWriter);
            }

            this.tagWriter = writer;

            if (this.Page != null && this.Page.Request != null && writer is System.Web.UI.Html32TextWriter)
            {
                System.Web.HttpBrowserCapabilities browser = this.Page.Request.Browser;
                if (browser.W3CDomVersion.Major > 0 || (browser.Browser == "Netscape" && browser.MajorVersion >= 5))
                {
                    if (!(browser.Browser == "Opera" && browser.MajorVersion < 7))
                    {
                        this.tagWriter = new HtmlTextWriter(writer.InnerWriter);
                    }
                }
            }

            return(this.tagWriter);
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Model_UsuarioAutenticado _autenticado = new Model_UsuarioAutenticado(fIdentity);

            System.Web.HttpBrowserCapabilities browser = Request.Browser;
            string Navegador = browser.Type.Substring(0, 6);

            ObjUsuario = Model_UsuarioAutenticado.ValidarObjUsuario(_autenticado);

            List <usuario> objUsuario = new List <usuario>();

            objUsuario = Mgr_Usuario.Get_Usuario(ObjUsuario.Id_usuario);
            foreach (var itemUsuario in objUsuario)
            {
                lbNombreUsuario.Text = itemUsuario.login;

                if (itemUsuario.trabajador != null && itemUsuario.trabajador.foto != "")
                {
                    imgLogo.ImageUrl = itemUsuario.trabajador.foto;
                }
                else
                {
                    imgLogo.ImageUrl = "~/archivos/foto_perfil/usuario.png";
                }
            }
            if (ObjUsuario.isRolDiferente())
            {
                menuPrin.Visible = false;
                if (Utilidades.VerificarUsuario(ObjUsuario.Rol, Request.Url.AbsoluteUri))
                {
                    Response.Redirect("~/source/sistema/MenuPrincipal/index.aspx");
                }
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Web.HttpBrowserCapabilities browser = Request.Browser;
            if (paramObj.ImportInputParameter(Server.MapPath("~\\Resources\\AMLParameter.xml")))
            {
                Page.Title        = paramObj.Title;
                lblTitle.Text     = paramObj.Title;
                webServicePostUrl = AMLParameterObject.GetPostUrl(paramObj.Url);
            }
            else
            {
                RequireInfor();
            }

            if (paramObj.listGlobalParameter != null && paramObj.listGlobalParameter.Count > 0)
            {
                // Show Global parameter
                //GenerateControl.ShowInput(GlobalPlaceHolder1, GlobalPlaceHolder2, paramObj.listGlobalParameter, browser);
                GenerateControl.ShowInput(PlaceHolderMain, paramObj.listGlobalParameter, browser, "Global Parameters");
            }

            //GenerateControl.ShowInput(InputPlaceHolder1, InputPlaceHolder2, paramObj.listInputParameter, browser);
            if (paramObj.listInputGroup != null)
            {
                paramObj.listInputGroup.Sort(); // Sort input by group name
                foreach (var groupName in paramObj.listInputGroup)
                {
                    var listParam = paramObj.listInputParameter.Where(x => (x.Group == groupName)).ToList();
                    GenerateControl.ShowInput(PlaceHolderMain, listParam, browser, groupName + " Parameters");
                }
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        #region Validacion del navegador
        System.Web.HttpBrowserCapabilities browser = Request.Browser;
        double jsVersion = Convert.ToDouble(browser["JavaScriptVersion"]);
        if (jsVersion >= 1.11)
        {
            // lblStatus.Text = jsVersion.ToString(); Response.Write("Ok");
        }
        else
        {
            Response.Redirect("~/BrowserCapabilities.html"); // Redireccionamos a la pagina donde le avisa la obsolecencia
        }
        #endregion

        var registroId = Request.QueryString["rId"]; // Este dato lo obtenemos del parametro en la URL
        registroId = registroId.ToUpper();
        switch (registroId)
        {
        case "SCC":
            lblTituloPrincipal.Text = "3er. Curso RENANP - San Cristobal de Las Casas";
            correoAlias             = "*****@*****.**";
            correoSubject           = "Curso RENANP San Cristobal - Registro en linea";
            break;

        case "AGS":
        default:
            lblTituloPrincipal.Text = "2do. Curso RENANP - Aguascalientes";
            correoAlias             = "*****@*****.**";
            correoSubject           = "Curso RENANP Aguascalientes - Registro en linea";
            break;
        }
        txtType.Text = registroId;
    }
Ejemplo n.º 6
0
        private void PropertyBrwser()
        {
            System.Web.HttpBrowserCapabilities browser = Request.Browser;

            string s = "Browser Capabilities\n"
                       + "Type = " + browser.Type + "\n"
                       + "Name = " + browser.Browser + "\n"
                       + "Version = " + browser.Version + "\n"
                       + "Major Version = " + browser.MajorVersion + "\n"
                       + "Minor Version = " + browser.MinorVersion + "\n"
                       + "Platform = " + browser.Platform + "\n"
                       + "Is Beta = " + browser.Beta + "\n"
                       + "Is Crawler = " + browser.Crawler + "\n"
                       + "Is AOL = " + browser.AOL + "\n"
                       + "Is Win16 = " + browser.Win16 + "\n"
                       + "Is Win32 = " + browser.Win32 + "\n"
                       + "Supports Frames = " + browser.Frames + "\n"
                       + "Supports Tables = " + browser.Tables + "\n"
                       + "Supports Cookies = " + browser.Cookies + "\n"
                       + "Supports VBScript = " + browser.VBScript + "\n"
                       + "Supports JavaScript = " +
                       browser.EcmaScriptVersion.ToString() + "\n"
                       + "Supports Java Applets = " + browser.JavaApplets + "\n"
                       + "Supports ActiveX Controls = " + browser.ActiveXControls
                       + "\n"
                       + "Supports JavaScript Version = " +
                       browser["JavaScriptVersion"] + "\n";
        }
Ejemplo n.º 7
0
    protected void darkTheme_Click(object sender, EventArgs e)
    {
        if (Session["ThemeSessionValue"] != null)
        {
            //Browser Details
            System.Web.HttpBrowserCapabilities browser = Request.Browser;

            Session["ThemeSessionValue"] = "DarkTheme";    //Override existing value and Set in the Session

            //Write to Cookie UserTheme - second check
            HttpCookie themeCookie;
            themeCookie = Request.Cookies["UserTheme" + browser.Browser];
            if (themeCookie == null)
            {
                //Cookie does not exist
                System.Diagnostics.Debug.WriteLine("*****Creating Cookie*****");
                Session["ThemeSessionValue"] = Session["ThemeSessionValue"].ToString();
                themeCookie         = new HttpCookie(name: "UserTheme" + browser.Browser, value: Session["ThemeSessionValue"].ToString());
                themeCookie.Expires = DateTime.Now.AddMonths(1);
                Response.Cookies.Add(themeCookie);
            }
            else
            {
                //Modify Cookie
                themeCookie.Value   = Session["ThemeSessionValue"].ToString();
                themeCookie.Expires = DateTime.Now.AddMonths(1);
                Response.Cookies.Add(themeCookie);
            }

            Response.Redirect("Default.aspx");
            Server.Transfer(Request.Path);
        }
    }
Ejemplo n.º 8
0
        public TestWebContext(string virtualPath, string page)
        {
            _out = new StringWriter();
            HttpWorkerRequest wr;
            AppDomain domain = Thread.GetDomain();

            // are we running within a valid AspNet AppDomain?
            string appPath = (string) domain.GetData(".appPath");
            if (appPath != null)
            {
                wr = new SimpleWorkerRequest(page, string.Empty, _out);
            }
            else
            {
                appPath = domain.BaseDirectory + "\\";
                wr = new SimpleWorkerRequest(virtualPath, appPath, page, string.Empty, _out);
            }
            HttpContext ctx = new HttpContext(wr);
            HttpContext.Current = ctx;
            HttpBrowserCapabilities browser = new HttpBrowserCapabilities();
            browser.Capabilities = new CaseInsensitiveHashtable(); //CollectionsUtil.CreateCaseInsensitiveHashtable();
            browser.Capabilities[string.Empty] = "Test User Agent"; // string.Empty is the key for "user agent"

            // avoids NullReferenceException when accessing HttpRequest.FilePath
            object virtualPathObject = ExpressionEvaluator.GetValue(null, "T(System.Web.VirtualPath).Create('/')");
            object cachedPathData = ExpressionEvaluator.GetValue(null, "T(System.Web.CachedPathData).GetRootWebPathData()");
            ExpressionEvaluator.SetValue(cachedPathData, "_virtualPath", virtualPathObject);
            ExpressionEvaluator.SetValue(cachedPathData, "_physicalPath", appPath);

            ctx.Request.Browser = browser;
            string filePath = ctx.Request.FilePath;
            _wr = wr;
        }
Ejemplo n.º 9
0
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        System.Web.HttpBrowserCapabilities browser = Request.Browser;
        string s = "Browser Capabilities<br>"
                   + "Type = " + browser.Type + "<br>"
                   + "Name = " + browser.Browser + "<br>"
                   + "Version = " + browser.Version + "<br>"
                   + "Major Version = " + browser.MajorVersion + "<br>"
                   + "Minor Version = " + browser.MinorVersion + "<br>"
                   + "Platform = " + browser.Platform + "<br>"
                   + "Is Beta = " + browser.Beta + "<br>"
                   + "Is Crawler = " + browser.Crawler + "<br>"
                   + "Is AOL = " + browser.AOL + "<br>"
                   + "Is Win16 = " + browser.Win16 + "<br>"
                   + "Is Win32 = " + browser.Win32 + "<br>"
                   + "Supports Frames = " + browser.Frames + "<br>"
                   + "Supports Tables = " + browser.Tables + "<br>"
                   + "Supports Cookies = " + browser.Cookies + "<br>"
                   + "Supports VBScript = " + browser.VBScript + "<br>"
                   + "Supports JavaScript = " +
                   browser.EcmaScriptVersion.ToString() + "<br>"
                   + "Supports Java Applets = " + browser.JavaApplets + "<br>"
                   + "Supports ActiveX Controls = " + browser.ActiveXControls
                   + "<br>"
                   + "Supports JavaScript Version = " + browser["JavaScriptVersion"] + "<br>"
                   + "User Agent = " + Request.ServerVariables["http_user_agent"] + "<br>";

        Label1.Text = s;
    }
Ejemplo n.º 10
0
        protected void lbNewsLetter_Click(object sender, EventArgs e)
        {
            pnlSuccess.Visible = false;
            if (Page.IsValid)
            {
                //if (IsValidUser())
                //{
                if (IsFirstTimeEmail())

                {
                    using (VaranegarEntities db = new VaranegarEntities())
                    {
                        NewsLetters nlEnter = new NewsLetters();
                        nlEnter.email    = txtNewsletter.Text;
                        nlEnter.IsDelete = false;
                        nlEnter.OS       = FindUserInfo.UserOS();
                        nlEnter.SubmitIP = Request.UserHostAddress;
                        System.Web.HttpBrowserCapabilities browser = Request.Browser;
                        nlEnter.Browser    = browser.Type;
                        nlEnter.SubmitDate = DateTime.Now;

                        db.NewsLetters.Add(nlEnter);
                        db.SaveChanges();
                        pnlSuccess.Visible = true;
                    }
                }
                //}
                //else
                //{
                //    pnlCaptcha.Visible = true;
                //    imgCaptcha.ImageUrl = "~/Captcha/CaptchaGeneratorForNewsletter.aspx";
                //    ViewState["cp"] = "1";
                //}
            }
        }
Ejemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Session["CookieValue"] = "Blank";
        System.Web.HttpBrowserCapabilities browser = Request.Browser;

        string s = "Browser Capabilities\n"
                   + "Type = " + browser.Type + "\n"
                   + "Name = " + browser.Browser + "\n"
                   + "Version = " + browser.Version + "\n"
                   + "Major Version = " + browser.MajorVersion + "\n"
                   + "Minor Version = " + browser.MinorVersion + "\n"
                   + "Platform = " + browser.Platform + "\n"
                   + "Is Beta = " + browser.Beta + "\n"
                   + "Is Crawler = " + browser.Crawler + "\n"
                   + "Is AOL = " + browser.AOL + "\n"
                   + "Is Win16 = " + browser.Win16 + "\n"
                   + "Is Win32 = " + browser.Win32 + "\n"
                   + "Supports Frames = " + browser.Frames + "\n"
                   + "Supports Tables = " + browser.Tables + "\n"
                   + "Supports Cookies = " + browser.Cookies + "\n"
                   + "Supports VBScript = " + browser.VBScript + "\n"
                   + "Supports JavaScript = " + browser.EcmaScriptVersion.ToString() + "\n"
                   + "Supports Java Applets = " + browser.JavaApplets + "\n"
                   + "Supports ActiveX Controls = " + browser.ActiveXControls + "\n"
                   + "Supports JavaScript Version = " + browser["JavaScriptVersion"] + "\n";

        if (Session["ThemeSessionValue"] != null)
        {
            CookieText.Text = "The browser is " + browser.Browser + " and the current theme is set to " + Session["ThemeSessionValue"].ToString();
        }
    }
Ejemplo n.º 12
0
        static public float GetInternetExplorerVersion()
        {
            //http://msdn.microsoft.com/en-us/library/ms537509%28v=vs.85%29.aspx
            // Returns the version of Internet Explorer or a -1
            // (indicating the use of another browser).
            float rv = -1;

            System.Web.HttpBrowserCapabilities browser = HttpContext.Current.Request.Browser;
            string agent = HttpContext.Current.Request.UserAgent;

            if (browser.Browser == "IE")
            {
                rv = (float)(browser.MajorVersion + browser.MinorVersion);
            }

            if (agent.Contains("rv:") || agent.Contains("Trident/7.0"))
            {
                rv = (float)11.0;
            }

            if (agent.Contains("Trident/4.0"))
            {
                rv = (float)8.0;
            }
            return(rv);
        }
Ejemplo n.º 13
0
        public static HttpContext CreateHttpContext()
        {
            HttpRequest request = new HttpRequest("", "http://localhost:19175/domain/", "p=1&n&=k");
            Hashtable browserCapabilities = new Hashtable { { "cookies", "true" } };
            HttpBrowserCapabilities browser = new HttpBrowserCapabilities();
            HttpResponse response = new HttpResponse(new StringWriter());
            HttpContext httpContext = new HttpContext(request, response);
            browser.Capabilities = browserCapabilities;
            request.Browser = browser;

            RouteValueDictionary routeValues = request.RequestContext.RouteData.Values;
            routeValues["area"] = "administration";
            routeValues["controller"] = "accounts";
            routeValues["action"] = "details";
            routeValues["language"] = "en";
            MapRoutes();

            IIdentity identity = Substitute.For<IIdentity>();
            identity.IsAuthenticated.Returns(true);
            identity.Name.Returns("1");

            httpContext.User = Substitute.For<IPrincipal>();
            httpContext.User.Identity.Returns(identity);

            return httpContext;
        }
Ejemplo n.º 14
0
    protected void getPeeps()
    {
        System.Web.HttpBrowserCapabilities browser = Request.Browser;
        List <Github.Users> lst = Github.GetADUsers(txtSearchStr.Text);
        string rsults           = string.Empty;

        for (int i = 0; i < lst.Count; i++)
        {
            if (browser.Browser == "IE" || browser.Browser == "Mozilla" || browser.Browser == "InternetExplorer" || browser.Browser == "Chrome")
            {
                if (((Github.Users)lst[i]).EmpPhoto == null)
                {
                    rsults = rsults + "<div class='card' style='width:25rem;'><div class='margin-fix'><span class='icon-size'><img class='card-img-top img-responsive rounded-circle' src='../Assets/O14_person_placeHolder_192_small.png' width='87' height='87' alt='Card image cap' /></span><h4 class='card-title'>" + ((Github.Users)lst[i]).DisplayName + "</h4><h6 class='card-title'>" + ((Github.Users)lst[i]).Department + " Department" + "<br /> " + ((Github.Users)lst[i]).EmployeeTitle + ", <i class='fa fa-map-marker'></i> " + ((Github.Users)lst[i]).office + "</h6> <b>Reports to: </b> " + ((Github.Users)lst[i]).Manager + "</h6> <br /><b>Level 2 Manager: </b> " + ((Github.Users)lst[i]).Level2Manager + "</h6><br /><i class='fa fa-phone-square'></i> " + ((Github.Users)lst[i]).PhoneNumber + " <br /><i class='fa fa-mobile'></i> " + ((Github.Users)lst[i]).Mobile + "</div></div><br />";
                }
                else
                {
                    rsults = rsults + "<div class='card' style='width:25rem;'><div class='margin-fix'><span class='icon-size'><img class='card-img-top img-responsive rounded-circle' src='data:image/png;base64," + ((Github.Users)lst[i]).EmpPhoto + "' width='87' height='87' alt='Card image cap' /></span><h4 class='card-title'>" + ((Github.Users)lst[i]).DisplayName + "</h4><h6 class='card-title'>" + ((Github.Users)lst[i]).Department + " Department" + "<br /> " + ((Github.Users)lst[i]).EmployeeTitle + ", <i class='fa fa-map-marker'></i> " + ((Github.Users)lst[i]).office + "</h6><b>Reports to: </b> " + ((Github.Users)lst[i]).Manager + "</h6><br /> <b>Level 2 Manager: </b> " + ((Github.Users)lst[i]).Level2Manager + "</h6><br /><i class='fa fa-phone-square'></i> " + ((Github.Users)lst[i]).PhoneNumber + "<br /><i class='fa fa-mobile'></i> " + ((Github.Users)lst[i]).Mobile + "</div></div><br />";
                }
            }
            else
            {
            }
        }
        lblResults.Text = rsults;
    }
Ejemplo n.º 15
0
        public void Log_ErrorInsert(string searchQuery)
        {
            using (VaranegarEntities db = new VaranegarEntities())
            {
                Log_SearchQueries leIn = new Log_SearchQueries();

                leIn.SearchQuery = searchQuery;
                leIn.SearchDate  = DateTime.Now;
                leIn.SearchIp    = Request.UserHostAddress;
                leIn.OS          = FindUserInfo.UserOS();
                if (Request.UrlReferrer != null)
                {
                    leIn.RefrallPage = Request.UrlReferrer.ToString();
                }
                else
                {
                    leIn.RefrallPage = "ورود مستقیم";
                }
                System.Web.HttpBrowserCapabilities browser = Request.Browser;
                leIn.browser = browser.Type;

                db.Log_SearchQueries.Add(leIn);
                db.SaveChanges();
            }
        }
Ejemplo n.º 16
0
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);

            AdminMasterPage master = Master as AdminMasterPage;

            master.CheckAuthenticated();
            VerifyAccessToThisPage();

            System.Web.HttpBrowserCapabilities browser = Request.Browser;
            if (browser.Browser == "IE" && browser.MajorVersion < 7)
            {
                if (Request.CurrentExecutionFilePath != @"/UnsupportedBrowser.aspx" && Request.CurrentExecutionFilePath != @"/Login.aspx")
                {
                    Response.Redirect(@"/UnsupportedBrowser.aspx", true);
                }
            }
            else
            {
                if (Request.CurrentExecutionFilePath == @"/UnsupportedBrowser.aspx")
                {
                    Response.Redirect(@"/", true);
                }
            }
        }
Ejemplo n.º 17
0
        public static void MostrarPdfModal(string NombreArchivo, string Titulo, int Alto, int Ancho)
        {
            System.Web.HttpBrowserCapabilities browser = HttpContext.Current.Request.Browser;
            string name = browser.Browser;

            if (name == "IE")
            {
                var RutaPdf = HttpContext.Current.Server.MapPath(Constantes.RutaPdf + NombreArchivo);
                System.IO.FileInfo toDownload = new System.IO.FileInfo(RutaPdf);
                if (toDownload.Exists)
                {
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + NombreArchivo);
                    HttpContext.Current.Response.AddHeader("Content-Length", toDownload.Length.ToString());
                    HttpContext.Current.Response.ContentType = "application/octet-stream";
                    HttpContext.Current.Response.WriteFile(RutaPdf);
                    HttpContext.Current.Response.Flush();
                }
            }
            else
            {
                string _baseAbrirPopup = "MostrarPdfModal('@NombreArchivo',@Ancho, @Alto, '@Titulo');";
                _baseAbrirPopup = _baseAbrirPopup.Replace("@NombreArchivo", NombreArchivo).Replace("@Ancho", Ancho.ToString()).Replace("@Alto", Alto.ToString()).Replace("@Titulo", Titulo);
                Anthem.Manager.RegisterStartupScript(typeof(string), Guid.NewGuid().ToString(), _baseAbrirPopup, true);
            }
        }
 public HttpBrowserCapabilitiesWrapper(HttpBrowserCapabilities httpBrowserCapabilities)
 {
     if (httpBrowserCapabilities == null) {
         throw new ArgumentNullException("httpBrowserCapabilities");
     }
     _browser = httpBrowserCapabilities;
 }
Ejemplo n.º 19
0
    public string BrowserGet()
    {
        System.Text.StringBuilder          strBrowser = new System.Text.StringBuilder();
        System.Web.HttpBrowserCapabilities browser    = System.Web.HttpContext.Current.Request.Browser;
        string strType = browser.Type;

        strBrowser.Append("<div style='font-size:11pt;font-weight:bold;'>Browser Capabilities</div>");
        strBrowser.Append("Type = " + browser.Type); strBrowser.Append("<br/>");
        strBrowser.Append("Name = " + browser.Browser); strBrowser.Append("<br/>");
        strBrowser.Append("Version = " + browser.Version); strBrowser.Append("<br/>");
        strBrowser.Append("Major Version = " + browser.MajorVersion); strBrowser.Append("<br/>");
        strBrowser.Append("Minor Version = " + browser.MinorVersion); strBrowser.Append("<br/>");
        strBrowser.Append("Platform = " + browser.Platform); strBrowser.Append("<br/>");
        strBrowser.Append("Is Beta = " + browser.Beta); strBrowser.Append("<br/>");
        strBrowser.Append("Is Crawler = " + browser.Crawler); strBrowser.Append("<br/>");
        strBrowser.Append("Is AOL = " + browser.AOL); strBrowser.Append("<br/>");
        strBrowser.Append("Is Win16 = " + browser.Win16); strBrowser.Append("<br/>");
        strBrowser.Append("Is Win32 = " + browser.Win32); strBrowser.Append("<br/>");
        strBrowser.Append("Supports Frames = " + browser.Frames); strBrowser.Append("<br/>");
        strBrowser.Append("Supports Tables = " + browser.Tables); strBrowser.Append("<br/>");
        strBrowser.Append("Supports Cookies = " + browser.Cookies); strBrowser.Append("<br/>");
        strBrowser.Append("Supports VBScript = " + browser.VBScript); strBrowser.Append("<br/>");
        strBrowser.Append("Supports JavaScript = " + browser.EcmaScriptVersion.ToString()); strBrowser.Append("<br/>");
        strBrowser.Append("Supports Java Applets = " + browser.JavaApplets); strBrowser.Append("<br/>");
        strBrowser.Append("Supports ActiveX Controls = " + browser.ActiveXControls); strBrowser.Append("<br/>");
        strBrowser.Append("Supports JavaScript Version = " + browser["JavaScriptVersion"]);

        //return strBrowser.ToString();
        return(strType);
    }
Ejemplo n.º 20
0
 protected void brsrCheck()
 {
     try
     {
         System.Web.HttpBrowserCapabilities browser1 = Request.Browser;
         if (browser1.Beta == true)
         {
             ClientScript.RegisterStartupScript(this.GetType(), "dis", "<script>alert('You are using Beta version of browser, it is not allowed');</script>");
             ((Button)Login1.FindControl("loginButton")).Enabled = false;
             return;
         }
         else if (Convert.ToString(browser1.Browser) == "Firefox" && Convert.ToInt32(browser1.MajorVersion) < 22)
         {
             ClientScript.RegisterStartupScript(this.GetType(), "dis", "<script>alert('You are using lower version of Firefox \\n Please use Firefox 22.0 or above');</script>");
             ((Button)Login1.FindControl("loginButton")).Enabled = false;
             return;
         }
         else if (Convert.ToString(browser1.Browser) == "IE" && Convert.ToInt32(browser1.MajorVersion) < 8)
         {
             ClientScript.RegisterStartupScript(this.GetType(), "dis", "<script>alert('You are using lower version of IE \\n Please use IE 8.0 or above');</script>");
             ((Button)Login1.FindControl("loginButton")).Enabled = false;
             return;
         }
     }
     catch (Exception exx)
     {
         Response.Write("<script language='javascript'> alert('" + exx.Message.ToString() + "')</script>");
         return;
     }
 }
Ejemplo n.º 21
0
        public void Insert_Log_LoginAttemp(Boolean IsSuccess)
        {
            using (MashadCarpetEntities db = new MashadCarpetEntities())
            {
                Log_LoginAttemps lmEnter = new Log_LoginAttemps();

                lmEnter.IP        = Request.UserHostAddress;
                lmEnter.VisitDate = DateTime.Now;

                if (Request.UrlReferrer != null)
                {
                    lmEnter.RefrallPage = Request.UrlReferrer.ToString();
                }
                else
                {
                    lmEnter.RefrallPage = "ورود مستقیم";
                }
                System.Web.HttpBrowserCapabilities browser = Request.Browser;
                lmEnter.Browser   = browser.Type;
                lmEnter.OS        = OSIdentify.OSName();
                lmEnter.Username  = txtEmail.Text;
                lmEnter.Password  = txtPass.Text;
                lmEnter.IsSuccess = IsSuccess;

                db.Log_LoginAttemps.Add(lmEnter);
                db.SaveChanges();
            }
        }
Ejemplo n.º 22
0
        private string getClientBrowser(HttpRequest req)
        {
            {
                System.Web.HttpBrowserCapabilities browser = Request.Browser;
                string s = "Type=" + browser.Type + ";"
                           + "Name=" + browser.Browser + ";"
                           + "Version=" + browser.Version + ";"
                           //+ "Major Version = " + browser.MajorVersion + "\n"
                           //+ "Minor Version = " + browser.MinorVersion + "\n"
                           + "Platform=" + browser.Platform + ";"
                           //+ "Is Beta = " + browser.Beta + ";"
                           //+ "Is Crawler = " + browser.Crawler + "\n"
                           //+ "Is AOL = " + browser.AOL + "\n"
                           //+ "Is Win16 = " + browser.Win16 + "\n"
                           //+ "Is Win32 = " + browser.Win32 + "\n"
                           //+ "Frames = " + browser.Frames + "\n"
                           //+ "Tables = " + browser.Tables + "\n"
                           + "Cookies=" + browser.Cookies;
                //+ "VBScript = " + browser.VBScript + "\n"
                //+ "JavaScript=" + browser.EcmaScriptVersion.ToString() + ";"
                //+ "Java Applets = " + browser.JavaApplets + "\n"
                //+ "ActiveX Controls = " + browser.ActiveXControls + "\n"
                //+ "JSVersion=" + browser["JavaScriptVersion"];

                return(s);
            }
        }
Ejemplo n.º 23
0
    protected void Page_PreInit(object sender, EventArgs e)
    {
        //Browser Details
        System.Web.HttpBrowserCapabilities browser = Request.Browser;

        //Read Cookie
        HttpCookie themeCookie;

        themeCookie = Request.Cookies["UserTheme" + browser.Browser];

        if (themeCookie == null)
        {
            System.Diagnostics.Debug.WriteLine("*****Creating Cookie*****");
            Session["ThemeSessionValue"] = "DarkTheme";// Default Theme is DarkTheme
            themeCookie         = new HttpCookie(name: "UserTheme" + browser.Browser, value: "DarkTheme");
            themeCookie.Expires = DateTime.Now.AddMonths(1);
            Response.Cookies.Add(themeCookie);
            Page.Theme = (string)Session["ThemeSessionValue"];  //REQUIRED to Set on STARTUP
        }
        else
        {
            Session["ThemeSessionValue"] = themeCookie.Value;   //Set in the Session Variable
            Page.Theme = (string)Session["ThemeSessionValue"];  //REQUIRED to Set on STARTUP
        }
    }
        public SessionTracker()
        {
            try
            {
                _context = HttpContext.Current;
                _expires = DateTime.Now.AddYears(1);
                IncrementVisitCount();
                _userHostAddress = _context.Request.UserHostAddress.ToString();
                if (_context.Request.UserAgent != null)
                {
                    _userAgent = _context.Request.UserAgent.ToString();
                }

                if ((_context.Request.UrlReferrer != null))
                {
                    SetOriginalReferrer(_context.Request.UrlReferrer.ToString());
                    _sessionReferrer = _context.Request.UrlReferrer.ToString();
                }

                if ((_context.Request.Url != null))
                {
                    SetOriginalURL(_context.Request.Url.ToString());
                    _sessionURL = _context.Request.Url.ToString();
                }
                _browser = _context.Request.Browser;
            }
            catch
            {
            }

        }
Ejemplo n.º 25
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        System.Web.HttpBrowserCapabilities browser = Request.Browser;
        string s = "名称 = " + browser.Browser + "\n";

        Label1.Text = s;
    }
 /// <summary>
 /// Constructs an instance of <cref see="FiftyOneBrowserCapabilities"/>
 /// </summary>
 public FiftyOneBrowserCapabilities(HttpBrowserCapabilities defaultBrowserCapabilities, HttpRequest request, Match match)
     : base()
 {
     _defaultBrowserCapabilities = defaultBrowserCapabilities;
     _request = request;
     _match = match;
 }
 /// <summary>
 /// Constructs a new instance of ClientCapability.
 /// See http://51degrees.mobi/Products/DeviceData/PropertyDictionary.aspx
 /// for a full list of available properties.
 /// All the properties used are non-lists and therefore the first
 /// item contained in the values list contains the only available value.
 /// </summary>
 public FiftyOneClientCapability(HttpBrowserCapabilities browserCaps)
 {
     if (browserCaps != null)
     {
         Initialise(browserCaps.Capabilities[Constants.FiftyOneDegreesProperties] as SortedList<string, string[]>);
     }
 }
 void CheckBrowserCaps()
 {
     System.Web.HttpBrowserCapabilities myBrowserCaps = Request.Browser;
     if (((System.Web.Configuration.HttpCapabilitiesBase)myBrowserCaps).Crawler)
     {
         SearchEngine = true;
     }
 }
Ejemplo n.º 29
0
        public static bool CheckClientIsMobile()
        {
            //判断是否是移动端访问
            System.Web.HttpBrowserCapabilities myBrowserCaps = HttpContext.Current.Request.Browser;
            bool isMobileDevice = ((System.Web.Configuration.HttpCapabilitiesBase)myBrowserCaps).IsMobileDevice;

            return(isMobileDevice);
        }
Ejemplo n.º 30
0
 protected void btnSearch_Click(object sender, ImageClickEventArgs e)
 {
     browser = Request.Browser;
     if (browser.IsMobileDevice == false)
     {
         txtSearch.Visible = true;
     }
 }
Ejemplo n.º 31
0
        private void CreateSimulatedRequest(Uri url)
        {
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator();
            simulator.SimulateRequest(url);

            var browserCaps = new HttpBrowserCapabilities { Capabilities = new Hashtable() };
            HttpContext.Current.Request.Browser = browserCaps;
        }
Ejemplo n.º 32
0
        protected void Application_Error(object sender, EventArgs e)
        {
            var    exception = Server.GetLastError();
            string host      = HttpContext.Current.Request.Url.Host;

            System.Web.HttpBrowserCapabilities browser = Request.Browser;
            String user = User.Identity.Name;

            if (user == "")
            {
                user = "******";
            }
            String JS = "$.ajax({ url : 'http://kal-rul.com/PHP/AJAX.php',  ";

            JS += "type: 'POST',  ";
            JS += "data : {call:'sendErrorEmail', to:'[email protected];[email protected]', ";
            JS += "subject:'Tortuga UAT - " + DateTime.Now + " - Error', ";
            JS += "timestamp:'" + DateTime.Now + "', ";
            JS += "browser:'" + browser.Type + "', ";
            JS += "user:'******', ";
            JS += "host:'" + host + "', ";
            JS += "errorMessage:'" + exception.Message.Replace("'", "\"").Replace("\r\n", "</br>") + "', ";
            JS += "trace:'" + exception.StackTrace.Replace("'", "\"").Replace("\r\n", "</br>");
            JS += "'}});";
            HttpContext.Current.Response.Write("<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script><script>" + JS + "</script>");
            Server.ClearError();
            var httpException = exception as HttpException;

            //Logging goes here

            var routeData = new RouteData();

            routeData.Values["controller"] = "Error";
            routeData.Values["action"]     = "Error";

            if (httpException != null)
            {
                if (httpException.GetHttpCode() == 404)
                {
                    routeData.Values["action"] = "NotFound";
                }
                Response.StatusCode = httpException.GetHttpCode();
            }
            else
            {
                Response.StatusCode = 500;
            }

            // Avoid IIS7 getting involved
            Response.TrySkipIisCustomErrors = true;

            // Execute the error controller
            IController        errorsController = new ErrorController();
            HttpContextWrapper wrapper          = new HttpContextWrapper(Context);
            var rc = new RequestContext(wrapper, routeData);

            errorsController.Execute(rc);
        }
 /// <summary>
 /// Constructs a new instance of ClientCapability.
 /// See http://51degrees.mobi/Products/DeviceData/PropertyDictionary.aspx
 /// for a full list of available properties.
 /// All the properties used are non-lists and therefore the first
 /// item contained in the values list contains the only available value.
 /// </summary>
 public FiftyOneClientCapability(HttpBrowserCapabilities browserCaps)
 {
     if (browserCaps != null)
     {
         Initialise(
             browserCaps.Capabilities[FiftyOne.Foundation.Mobile.Detection.Constants.FiftyOneDegreesProperties] 
                 as SortedList<string, List<string>>);
     }
 }
        public async Task CreateAsync(AuthenticationTokenCreateContext context)
        {
            try
            {
                var clientid = context.Ticket.Properties.Dictionary["as:client_id"];

                if (string.IsNullOrEmpty(clientid))
                    return;

                // Gera um ID unico para o RefreshToken
                var refreshTokenId = Guid.NewGuid().ToString("n");

                // Pega o tempo de expiração (em minuto) do token do contexto do Owin
                var refreshTokenLifeTime = context.OwinContext.Get<string>("as:clientRefreshTokenLifeTime");

                // Identifica o Browser
                var userAgent = HttpContext.Current.Request.UserAgent;
                var userBrowser = new HttpBrowserCapabilities { Capabilities = new Hashtable { { string.Empty, userAgent } } };
                var factory = new BrowserCapabilitiesFactory();
                factory.ConfigureBrowserCapabilities(new NameValueCollection(), userBrowser);
                var browser = userBrowser.Browser;

                var issuedUtc = DateTime.UtcNow;
                var expiresUtc = issuedUtc.AddMinutes(3); //issuedUtc.AddMonths(Convert.ToInt32(refreshTokenLifeTime));

                // Define os dados do RefreshToken
                var token = new RefreshToken
                {
                    Id = HashHelper.GetHash(refreshTokenId),
                    ClientId = clientid,
                    Browser = browser,
                    Subject = context.Ticket.Identity.Name,
                    IssuedUtc = issuedUtc,
                    ExpiresUtc = expiresUtc
                };

                // Define o IssuedUtc e o ExpiresUtc do ticket para determinar o quanto tempo o token vai ser válido
                context.Ticket.Properties.IssuedUtc = token.IssuedUtc;
                context.Ticket.Properties.ExpiresUtc = token.ExpiresUtc;

                // Serializa o ticket para ser gravado na base de dados
                var ticketSerializer = new TicketSerializer();
                token.ProtectedTicket = ticketSerializer.Serialize(context.Ticket);

                // Grava o ticket na base de dados
                var refreshTokenDomain = DependecyConfig.Container.GetInstance<IRefreshTokenDomain>();
                var result = await refreshTokenDomain.CreateAsync(token);

                if (result)
                    context.SetToken(refreshTokenId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Show list of input
        /// </summary>
        /// <param name="inputPlace1"> div of clolumn 1 </param>
        /// <param name="inputPlace2"> div of clolumn 2 </param>
        /// <param name="inputParam"> list of Parameter Object </param>
        /// <param name="browser"> Detect Browser </param>
        public static void ShowInput(PlaceHolder inputPlace1, PlaceHolder inputPlace2, List<AMLParam> inputParam, HttpBrowserCapabilities browser)
        {
            if (inputParam == null || inputParam.Count == 0)
            {
                inputPlace1.Controls.Add(new LiteralControl("<h3>No web service input</h3>"));
                return;
            }
            int count = 0;
            for (int i = 0; i < inputParam.Count; i++) //MLParameter param in inputParam)
            {
                Literal lcssFormGroup = new Literal();
                lcssFormGroup.Text = "<div class=\"form-group\">";
                Literal ldiv = new Literal();
                ldiv.Text = "</div>";

                AMLParam param = inputParam[i];
                Label lbl = new Label();
                if(string.IsNullOrEmpty(param.Alias))
                    lbl.Text = textInfo.ToTitleCase(param.Name);
                else lbl.Text = textInfo.ToTitleCase(param.Alias);
                lbl.ID = "lbl" + param + count++;
                lbl.Attributes.Add("Class", "fieldname");

                int numberOnPlace1 = inputParam.Count / 2;
                if(inputPlace2 == null)
                {
                    numberOnPlace1 = inputParam.Count;
                }

                if (i <= numberOnPlace1)
                {
                    inputPlace1.Controls.Add(lcssFormGroup);
                    inputPlace1.Controls.Add(lbl);

                    foreach (var control in GenerateInputControl(param, browser))
                    {
                        inputPlace1.Controls.Add(control);
                    }

                    if (!string.IsNullOrEmpty(param.Description)) inputPlace1.Controls.Add(new LiteralControl(string.Format("<div style=\"width=:100%\"><samp>{0}</samp></div>", param.Description)));
                    inputPlace1.Controls.Add(ldiv);

                }
                else
                {
                    inputPlace2.Controls.Add(lcssFormGroup);
                    inputPlace2.Controls.Add(lbl);
                    foreach (var control in GenerateInputControl(param, browser))
                    {
                        inputPlace2.Controls.Add(control);
                    }
                    if (!string.IsNullOrEmpty(param.Description)) inputPlace2.Controls.Add(new LiteralControl(string.Format("<div style=\"width=:100%\"><samp>{0}</samp></div>", param.Description)));
                    inputPlace2.Controls.Add(ldiv);
                }
            }
        }
Ejemplo n.º 36
0
 /// <summary>
 /// Returns a HttpBrowserCapabilities object from a UserAgent string
 /// </summary>
 /// <param name="userAgent">UserAgent from Browser</param>
 public BrowserCap(string userAgent)
 {
     var browser = new HttpBrowserCapabilities
     {
         Capabilities = new Hashtable { { string.Empty, userAgent } }
     };
     var factory = new BrowserCapabilitiesFactory();
     factory.ConfigureBrowserCapabilities(new NameValueCollection(), browser);
     Browser = browser;
 }
Ejemplo n.º 37
0
    public string BrowserDetails(System.Web.HttpBrowserCapabilities browser)
    {
        string      response = "";
        IPHostEntry Host     = default(IPHostEntry);
        string      Hostname = null;

        Hostname = System.Environment.MachineName;
        Host     = Dns.GetHostEntry(Hostname);
        foreach (IPAddress IP in Host.AddressList)
        {
            if (IP.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
            {
                response = "IP Address = " + Convert.ToString(IP) + "<br />";
            }
        }
        System.Web.HttpContext context = System.Web.HttpContext.Current;
        string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

        if (!string.IsNullOrEmpty(ipAddress))
        {
            string[] addresses = ipAddress.Split(',');
            if (addresses.Length != 0)
            {
                response += addresses[0];
            }
        }

        response += context.Request.ServerVariables["REMOTE_ADDR"];

        response += "<b>Browser Capabilities</b><br />"
                    + "Type = " + browser.Type + "<br />"
                    + "Name = " + browser.Browser + "<br />"
                    + "Version = " + browser.Version + "<br />"
                    + "Major Version = " + browser.MajorVersion + "<br />"
                    + "Minor Version = " + browser.MinorVersion + "<br />"
                    + "Platform = " + browser.Platform + "<br />"
                    + "Is Beta = " + browser.Beta + "<br />"
                    + "Is Crawler = " + browser.Crawler + "<br />"
                    + "Is AOL = " + browser.AOL + "<br />"
                    + "Is Win16 = " + browser.Win16 + "<br />"
                    + "Is Win32 = " + browser.Win32 + "<br />"
                    + "Supports Frames = " + browser.Frames + "<br />"
                    + "Supports Tables = " + browser.Tables + "<br />"
                    + "Supports Cookies = " + browser.Cookies + "<br />"
                    + "Supports VBScript = " + browser.VBScript + "<br />"
                    + "Supports JavaScript = " +
                    browser.EcmaScriptVersion.ToString() + "<br />"
                    + "Supports Java Applets = " + browser.JavaApplets + "<br />"
                    + "Supports ActiveX Controls = " + browser.ActiveXControls
                    + "<br />"
                    + "Supports JavaScript Version = " +
                    browser["JavaScriptVersion"] + "<br />";

        return(response);
    }
Ejemplo n.º 38
0
    protected void Page_Init(object sender, EventArgs e)
    {
        System.Web.HttpBrowserCapabilities browser = Request.Browser;
        string sType = browser.Type;
        string sName = browser.Browser;
        string szCSS;
        string _url = "";

        if (Request.RawUrl.IndexOf("?") > 0)
        {
            _url = Request.RawUrl.Substring(0, Request.RawUrl.IndexOf("?"));
        }
        else
        {
            _url = Request.RawUrl;
        }
        if (browser.Browser.ToLower().Contains("firefox"))
        {
            szCSS = "css/main-ff.css";
        }
        else
        {
            if (browser.Browser.ToLower().Contains("safari") || browser.Browser.ToLower().Contains("apple"))
            {
                szCSS = "css/main-ch.css";
            }
            else
            {
                szCSS = "css/main-ie.css";
            }
        }
        System.Text.StringBuilder b = new System.Text.StringBuilder();
        b.AppendLine("");
        if (_url.Contains("AJAX Pages"))
        {
            b.AppendLine("<link rel='shortcut icon' href='../Registration/icon.ico' />");
        }
        else
        {
            b.AppendLine("<link rel='shortcut icon' href='Registration/icon.ico' />");
        }
        b.AppendLine("<script type='text/javascript' src='js/CustomControls.ConfirmMessageJS.js'></script>");
        b.AppendLine("<script type='text/javascript' src='js/CustomControls.ContextMenuJS.js'></script>");
        b.AppendLine("<script type='text/javascript' src='js/CustomControls.GridViewJS.js'></script>");
        b.AppendLine("<script type='text/javascript' src='nitobi.callout/nitobi.toolkit.js'></script>");
        b.AppendLine("<script type='text/javascript' src='nitobi.callout/nitobi.callout.js'></script>");
        b.AppendLine("<link href='css/css.css' rel='stylesheet' type='text/css' />");
        b.AppendLine("<link type='text/css' rel='stylesheet' href='css/intake-sheet-ff.css' />");
        b.AppendLine("<link href='Css/UI.css' rel='stylesheet' type='text/css' />");
        b.AppendLine("<link href='nitobi.callout/nitobi.callout.css' rel='stylesheet' type='text/css' />");
        b.AppendLine("<link href='css/style.css'  rel='stylesheet' type='text/css'  />");
        b.AppendLine("<link href='" + szCSS + "' type='text/css' rel='Stylesheet' />");
        b.AppendLine("<link href='Css/mainmaster.css' rel='stylesheet' type='text/css' />");
        this.masterhead.InnerHtml = b.ToString();
    }
Ejemplo n.º 39
0
        public String GetIPAddress()
        {
            String ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            if (string.IsNullOrEmpty(ip))
            {
                ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            }
            System.Web.HttpBrowserCapabilities browser = Request.Browser;
            return(ip + " " + browser.Type);
        }
Ejemplo n.º 40
0
        public static HttpBrowserCapabilities GetClientBrowser(this string useragent)
        {
            var browser = new HttpBrowserCapabilities
            {
                Capabilities = new Hashtable { { string.Empty, useragent } }
            };
            var factory = new BrowserCapabilitiesFactory();
            factory.ConfigureBrowserCapabilities(new NameValueCollection(), browser);

            return browser;
        }
Ejemplo n.º 41
0
        public static string GetBrowserDetails()

        {
            string browserDetails = string.Empty;

            System.Web.HttpBrowserCapabilities browser = HttpContext.Current.Request.Browser;

            browserDetails = browser.Browser;

            return(browserDetails);
        }
Ejemplo n.º 42
0
        private bool BrowserIsSupported()
        {
            System.Web.HttpBrowserCapabilities browser = Request.Browser;

            if (_supportedMatrix.ContainsKey(browser.Browser))
            {
                return(Double.Parse(browser.Version, System.Globalization.CultureInfo.InvariantCulture) >= _supportedMatrix[browser.Browser]);
            }

            return(true);
        }
        /// <summary>
        /// Gets the browser capabilities.
        /// </summary>
        /// <param name="userAgent">The user agent.</param>
        /// <param name="headers">The headers.</param>
        /// <returns></returns>
        public HttpBrowserCapabilities GetBrowserCapabilities(string userAgent, NameValueCollection headers)
        {
            HttpBrowserCapabilities browserCaps = new HttpBrowserCapabilities();
            Hashtable hashtable = new Hashtable(180, StringComparer.OrdinalIgnoreCase);
            hashtable[string.Empty] = userAgent; // The actual method uses client target
            browserCaps.Capabilities = hashtable;

            var capsFactory = new System.Web.Configuration.BrowserCapabilitiesFactory();
            capsFactory.ConfigureBrowserCapabilities(headers, browserCaps);
            capsFactory.ConfigureCustomCapabilities(headers, browserCaps);
            return browserCaps;
        }
		public static HttpCapabilitiesBase GetConfigCapabilities (string configKey, HttpRequest request)
		{
			string ua = request.ClientTarget;
			if (ua == null)
				ua = request.UserAgent;

			HttpBrowserCapabilities bcap = new HttpBrowserCapabilities ();
			bcap.useragent = ua;
			bcap.capabilities = CapabilitiesLoader.GetCapabilities (ua);
			bcap.Init ();
			return bcap;
		}
        /// <summary>
        /// Creates a dictionary of capabilites for the requesting device based on both the 
        /// current capabilities assigned by Microsoft, and the results from 51Degrees.
        /// </summary>
        /// <param name="results">The detection results.</param>
        /// <param name="currentCapabilities">The current capabilities assigned by .NET.</param>
        /// <returns>A dictionary of capabilities for the request.</returns>
        internal static IDictionary EnhancedCapabilities(SortedList<string, string[]> results, HttpBrowserCapabilities currentCapabilities)
        {
            // Use the base class to create the initial list of capabilities.
            IDictionary capabilities = new Hashtable();

            // Add the capabilities for the device.
            EnhancedCapabilities(results, capabilities, currentCapabilities);

            // Initialise any capability values that rely on the settings
            // from the device data source.
            Init(capabilities);

            return capabilities;
        }
Ejemplo n.º 46
0
        /// <summary>
        /// Checks the properties of the HttpBrowserCapabilities instance passed
        /// into the method for the property name contained in the property parameters
        /// string value.
        /// </summary>
        /// <param name="property">Property name to be found.</param>
        /// <param name="capabilities">Capabilities collection to be used.</param>
        /// <returns>If the property exists then return the associated value, otherwise null.</returns>
        private static string GetHttpBrowserCapabilitiesPropertyValue(string property, HttpBrowserCapabilities capabilities)
        {
            Type controlType = capabilities.GetType();
            System.Reflection.PropertyInfo propertyInfo = controlType.GetProperty(property);
            if (propertyInfo != null && propertyInfo.CanRead)
                return propertyInfo.GetValue(capabilities, null).ToString();

            // Try browser capabilities next.
            string value = capabilities[property];
            if (value != null)
                return value;

            return null;
        }
 internal HttpBrowserCapabilities GetHttpBrowserCapabilities(HttpRequest request)
 {
     if (request == null)
     {
         throw new ArgumentNullException("request");
     }
     NameValueCollection headers = request.Headers;
     HttpBrowserCapabilities browserCaps = new HttpBrowserCapabilities();
     Hashtable hashtable = new Hashtable(180, StringComparer.OrdinalIgnoreCase);
     hashtable[string.Empty] = HttpCapabilitiesDefaultProvider.GetUserAgent(request);
     browserCaps.Capabilities = hashtable;
     this.ConfigureBrowserCapabilities(headers, browserCaps);
     this.ConfigureCustomCapabilities(headers, browserCaps);
     return browserCaps;
 }
        /// <summary>
        /// Constructs an instance of <cref see="FiftyOneBrowserCapabilities"/>
        /// </summary>
        /// <param name="currentCapabilities">Capabilities provided by Microsoft.</param>
        /// <param name="overrideCapabilities">New capabilities provided by 51Degrees.mobi. Can not be null.</param>
        public FiftyOneBrowserCapabilities(HttpBrowserCapabilities currentCapabilities, IDictionary overrideCapabilities)
        {
            // Initialise the hashtable for capabilities.
            Capabilities = new Hashtable();

            // Copy the keys from both the original and new capabilities.
            foreach (object key in currentCapabilities.Capabilities.Keys)
                Capabilities[key] = currentCapabilities.Capabilities[key];
            foreach (object key in overrideCapabilities.Keys)
                Capabilities[key] = overrideCapabilities[key];

            // Copy the adapters from the original.
            foreach (object key in currentCapabilities.Adapters.Keys)
                Adapters.Add(key, currentCapabilities.Adapters[key]);

            // Copy the browsers from the original to prevent the Browsers
            // property returning null.
            if (currentCapabilities.Browsers != null)
                foreach (string browser in currentCapabilities.Browsers)
                    AddBrowser(browser);
        }
 private bool BlackberryProcess(NameValueCollection headers, HttpBrowserCapabilities browserCaps)
 {
     IDictionary capabilities = browserCaps.Capabilities;
     string target = browserCaps[string.Empty];
     RegexWorker worker = new RegexWorker(browserCaps);
     if (!worker.ProcessRegex(target, @"BlackBerry(?'deviceName'\w+)/(?'version'(?'major'\d+)(\.(?'minor'\d+)?)\w*)"))
     {
         return false;
     }
     capabilities["layoutEngine"] = "BlackBerry";
     capabilities["browser"] = "BlackBerry";
     capabilities["majorversion"] = worker["${major}"];
     capabilities["minorversion"] = worker["${minor}"];
     capabilities["type"] = worker["BlackBerry${major}"];
     capabilities["mobileDeviceModel"] = worker["${deviceName}"];
     capabilities["isMobileDevice"] = "true";
     capabilities["version"] = worker["${version}"];
     capabilities["ecmascriptversion"] = "3.0";
     capabilities["javascript"] = "true";
     capabilities["javascriptversion"] = "1.3";
     capabilities["w3cdomversion"] = "1.0";
     capabilities["supportsAccesskeyAttribute"] = "true";
     capabilities["tagwriter"] = "System.Web.UI.HtmlTextWriter";
     capabilities["cookies"] = "true";
     capabilities["frames"] = "true";
     capabilities["javaapplets"] = "true";
     capabilities["supportsCallback"] = "true";
     capabilities["supportsDivNoWrap"] = "false";
     capabilities["supportsFileUpload"] = "true";
     capabilities["supportsMultilineTextBoxDisplay"] = "true";
     capabilities["supportsXmlHttp"] = "true";
     capabilities["tables"] = "true";
     capabilities["canInitiateVoiceCall"] = "true";
     browserCaps.AddBrowser("BlackBerry");
     this.BlackberryProcessGateways(headers, browserCaps);
     bool ignoreApplicationBrowsers = false;
     this.BlackberryProcessBrowsers(ignoreApplicationBrowsers, headers, browserCaps);
     return true;
 }
Ejemplo n.º 50
0
        public HttpContextProxy(String fileName, String queryString)
            : base()
        {
            MemoryStream responseStream = new MemoryStream();
            TextWriter responseWriter = new StreamWriter(responseStream);
            HttpWorkerRequest wr = new SimpleWorkerRequest("/", @"C:\inetpub\wwwroot\", fileName, queryString, responseWriter);
            HttpContext context = new HttpContext(wr);
            HttpBrowserCapabilities browser = new HttpBrowserCapabilities();
            browser.SetFieldValue("_items", new Hashtable());
            context.Request.Browser = browser;

            HttpContext previousContext = HttpContext.Current;
            HttpContext.Current = context;

            this._context = context;
            this._previousContext = previousContext;
            this._responseStream = responseStream;
            this._responseWriter = responseWriter;

            IHttpSessionState container = new HttpSessionStateContainer(Guid.NewGuid().ToString(), new SessionStateItemCollection(), new HttpStaticObjectsCollection(), 20, true, HttpCookieMode.AutoDetect, SessionStateMode.InProc, false);
            this.SetSessionState(container);
        }
 private bool ChromeProcess(NameValueCollection headers, HttpBrowserCapabilities browserCaps)
 {
     IDictionary capabilities = browserCaps.Capabilities;
     string target = browserCaps[string.Empty];
     RegexWorker worker = new RegexWorker(browserCaps);
     if (!worker.ProcessRegex(target, @"Chrome/(?'version'(?'major'\d+)(\.(?'minor'\d+)?)\w*)"))
     {
         return false;
     }
     worker.ProcessRegex(browserCaps[string.Empty], @"AppleWebKit/(?'layoutVersion'\d+)");
     capabilities["layoutEngine"] = "WebKit";
     capabilities["layoutEngineVersion"] = worker["${layoutVersion}"];
     capabilities["browser"] = "Chrome";
     capabilities["majorversion"] = worker["${major}"];
     capabilities["minorversion"] = worker["${minor}"];
     capabilities["type"] = worker["Chrome${major}"];
     capabilities["version"] = worker["${version}"];
     capabilities["ecmascriptversion"] = "3.0";
     capabilities["javascript"] = "true";
     capabilities["javascriptversion"] = "1.7";
     capabilities["w3cdomversion"] = "1.0";
     capabilities["supportsAccesskeyAttribute"] = "true";
     capabilities["tagwriter"] = "System.Web.UI.HtmlTextWriter";
     capabilities["cookies"] = "true";
     capabilities["frames"] = "true";
     capabilities["javaapplets"] = "true";
     capabilities["supportsCallback"] = "true";
     capabilities["supportsDivNoWrap"] = "false";
     capabilities["supportsFileUpload"] = "true";
     capabilities["supportsMaintainScrollPositionOnPostback"] = "true";
     capabilities["supportsMultilineTextBoxDisplay"] = "true";
     capabilities["supportsXmlHttp"] = "true";
     capabilities["tables"] = "true";
     browserCaps.AddBrowser("Chrome");
     this.ChromeProcessGateways(headers, browserCaps);
     bool ignoreApplicationBrowsers = false;
     this.ChromeProcessBrowsers(ignoreApplicationBrowsers, headers, browserCaps);
     return true;
 }
        /// <summary>
        /// Generates the HTML to display a nicely formatted thumbnail image of the specified <paramref name="galleryObject"/>, including a
        /// border, shadows and (possibly) rounded corners.
        /// </summary>
        /// <param name="galleryObject">The gallery object to be used as the source for the thumbnail image.</param>
        /// <param name="gallerySettings">The gallery settings that govern display of the <paramref name="galleryObject"/>.</param>
        /// <param name="browserCaps">The browser capabilities. This may be found at Request.Browser.</param>
        /// <param name="includeHyperlinkToObject">if set to <c>true</c> wrap the image tag with a hyperlink so the user can click through
        /// to the media object view of the item.</param>
        /// <param name="allowAlbumTextWrapping">if set to <c>true</c> the album title is allowed to wrap to a second line if needed.
        /// Set to <c>false</c> when vertical space is limited.</param>
        /// <returns>
        /// Returns HTML that displays a nicely formatted thumbnail image of the specified <paramref name="galleryObject"/>
        /// </returns>
        public static string GenerateThumbnailHtml(IGalleryObject galleryObject, IGallerySettings gallerySettings, HttpBrowserCapabilities browserCaps, bool includeHyperlinkToObject, bool allowAlbumTextWrapping)
        {
            if (IsInternetExplorer1To8(browserCaps))
            {
                return GenerateThumbnailHtmlForIE1To8(galleryObject, gallerySettings, includeHyperlinkToObject, allowAlbumTextWrapping);
            }

            return GenerateThumbnailHtmlForStandardBrowser(galleryObject, gallerySettings, includeHyperlinkToObject, allowAlbumTextWrapping);
        }
 public bool IsSupported(HttpBrowserCapabilities browser)
 {
     return true;
 }
 public virtual void ConfigureCustomCapabilities(NameValueCollection headers, HttpBrowserCapabilities browserCaps)
 {
 }
        /// <summary>
        /// Determines whether the browser specified in <paramref name="browserCaps" /> is Internet Explorer 1 to 8.
        /// </summary>
        /// <param name="browserCaps">The browser capabilities. This may be found at Request.Browser.</param>
        /// <returns>
        /// 	<c>true</c> if browser is Internet Explorer 1 to 8; otherwise, <c>false</c>.
        /// </returns>
        private static bool IsInternetExplorer1To8(HttpBrowserCapabilities browserCaps)
        {
            bool isIE1To8 = false;

            if (browserCaps.Browser.Equals("IE", StringComparison.OrdinalIgnoreCase))
            {
                decimal version;
                if (Decimal.TryParse(browserCaps.Version, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out version) && (version < (decimal)9.0))
                {
                    isIE1To8 = true;
                }
            }

            return isIE1To8;
        }
Ejemplo n.º 56
0
        /// <summary>
        /// Adds the capabilities provided into the existing dictionary of capabilities
        /// already assigned by Microsoft.
        /// </summary>
        /// <param name="currentCapabilities"></param>
        /// <param name="overrideCapabilities"></param>
        private static HttpBrowserCapabilities AddNewCapabilities(HttpBrowserCapabilities currentCapabilities, IDictionary overrideCapabilities)
        {
            // We can't do anything with null capabilities. Return the current ones.
            if (overrideCapabilities == null)
                return currentCapabilities;

            // Use our own capabilities object.
            return new FiftyOneBrowserCapabilities(currentCapabilities, overrideCapabilities);
        }
Ejemplo n.º 57
0
		// ReSharper disable once UnusedParameter.Local
		private HttpBrowserCapabilitiesBase ConvertBrowser(HttpBrowserCapabilities browser)
		{
			return null;
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="JavascriptHelper"/> class.
		/// </summary>
		/// <param name="controller">The controller.</param>
		/// <param name="key">The key.</param>
		public JavascriptHelper(Controller controller, string key)
		{
			this.context = null;
			this.contextVars = controller.PropertyBag;
			this.id = key;
			this.browCaps = controller.Context.UnderlyingContext.Request.Browser;
            cacheProvider = controller.Context.Services.CacheProvider;
            GetJSSegments(controller.Context);
			Init();

		}
Ejemplo n.º 59
0
        private static HttpBrowserCapabilities GetBrowserCaps(string user_agent)
        {
            if (String.IsNullOrEmpty(user_agent))
            {
                HttpContext context;
                if (!EnsureHttpContext(out context))
                    return null;

                return context.Request.Browser;
            }
            else
            {
                NameValueCollection headers = new NameValueCollection();
                headers["User-Agent"] = user_agent;

                HttpBrowserCapabilities browserCaps = new HttpBrowserCapabilities();
                Hashtable hashtable = new Hashtable(180, StringComparer.OrdinalIgnoreCase);
                hashtable[string.Empty] = user_agent; // The actual method uses client target   
                browserCaps.Capabilities = hashtable;

                //var capsFactory = new System.Web.Configuration.BrowserCapabilitiesFactory();
                //capsFactory.ConfigureBrowserCapabilities(headers, browserCaps);
                //capsFactory.ConfigureCustomCapabilities(headers, browserCaps);

                // use System.Web.Configuration.BrowserCapabilitiesFactory dynamically since Mono does not have this defined
                // Following code emits DynamicMethod delegate lazily and performs code commented above.
                
                // Note: absolutely no performance overhead.
                // This should be removed when the type will be defined on Mono.
                var configureCapsMethod = ConfigureCapsMethod;
                if (configureCapsMethod != null)
                    configureCapsMethod(headers, browserCaps);

                return browserCaps;
            }
        }
        static IEnumerable<Control> GenerateInputControl(AMLParam param, HttpBrowserCapabilities browser)
        {
            if (param.StrEnum != null && param.StrEnum.Count > 3)           // Drop list
            {
                yield return GenerateDropdownList(param);
            }
            else if (param.StrEnum != null && param.StrEnum.Count <= 3 && param.StrEnum.Count > 0)     // Radio Button
            {
                yield return GenerateRadio(param);
            }
            else if (param.Type.ToLower() == "integer")   // slider number Integer
            {
                TextBox txt = new TextBox();
                txt.ID = param.Name;
                txt.Text = param.DefaultValue;
                txt.Attributes.Add("Class", "amount form-control form-control-number");
                if (param.Type == "integer")
                    txt.TextMode = TextBoxMode.Number;
                if(browser.Browser.ToLower() == "internetexplorer")
                {
                    yield return GenerateSliderHTML(param, "1");
                    yield return txt;
                    yield return new LiteralControl("</div>");  // end of div
                    yield return GenerateScriptSlideIE(param);
                }

                else
                {
                    yield return GenerateSliderHTML(param, "1");
                    yield return txt;
                    yield return new LiteralControl("</div>");  // end of div
                    yield return GenerateScriptSlideHTML(param);
                }
            }
            else if (param.Type.ToLower() == "number")   // slider number Integer
            {
                TextBox txt = new TextBox();
                txt.ID = param.Name;
                txt.Text = param.DefaultValue;
                txt.Attributes.Add("Class", "amount form-control form-control-number");
                if (browser.Browser.ToLower() == "internetexplorer")
                {
                    yield return GenerateSliderHTML(param, "0.01");
                    yield return txt;
                    yield return new LiteralControl("</div>");  // end of div
                    yield return GenerateScriptSlideIE(param);
                }

                else
                {
                    yield return GenerateSliderHTML(param, "0.01");
                    yield return txt;
                    yield return new LiteralControl("</div>");  // end of div
                    yield return GenerateScriptSlideHTML(param);
                }
            }
            else
            {
                TextBox txt = new TextBox();
                txt.ID = param.Name;
                txt.Text = param.DefaultValue;
                txt.Attributes.Add("Class", "form-control");
                if (param.Type == "integer")
                    txt.TextMode = TextBoxMode.Number;

                yield return txt;
            }
        }