Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. web mobile application

web mobile application

Scheduled Pinned Locked Moved ASP.NET
tutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tek 2009
    wrote on last edited by
    #1

    how to restrict access to a web application just for mobile terminals,( not having access from a pc) thinks

    D 1 Reply Last reply
    0
    • T tek 2009

      how to restrict access to a web application just for mobile terminals,( not having access from a pc) thinks

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      I use the following code snipet to determine if a user is visiting my web page from a Blackberry. (the default mobile device supported by my orgainization) I believe this would work to detect any mobile deveice.

      If (Request.Headers("X-Wap-Profile").ToString().Length > 0) Then
      ' This request is coming from a mobile device
      End If

      Good luck. :thumbsup:

      T 1 Reply Last reply
      0
      • D David Mujica

        I use the following code snipet to determine if a user is visiting my web page from a Blackberry. (the default mobile device supported by my orgainization) I believe this would work to detect any mobile deveice.

        If (Request.Headers("X-Wap-Profile").ToString().Length > 0) Then
        ' This request is coming from a mobile device
        End If

        Good luck. :thumbsup:

        T Offline
        T Offline
        tek 2009
        wrote on last edited by
        #3

        thinks a lot but i'm testing this code:

        bool IsMobi = false;

            if (Request.Headers\["X-Wap-Profile"\] != null)
            {
                Response.Redirect("erreur.aspx", true);
              }
            else {
                if (Request.Headers\["X-Wap-Profile"\].ToString().Length > 0)
                {
                    IsMobi = true;
                    Response.Redirect("login.aspx", true);
                }
                else
                {
                    Response.Redirect("erreur.aspx", true);
                }
            }   
           
        }}
        

        but he dosen't work correctly, i detect that "Request.Headers["X-Wap-Profile"] != null" is null, i testing from a pda hp and o mobile

        B 1 Reply Last reply
        0
        • T tek 2009

          thinks a lot but i'm testing this code:

          bool IsMobi = false;

              if (Request.Headers\["X-Wap-Profile"\] != null)
              {
                  Response.Redirect("erreur.aspx", true);
                }
              else {
                  if (Request.Headers\["X-Wap-Profile"\].ToString().Length > 0)
                  {
                      IsMobi = true;
                      Response.Redirect("login.aspx", true);
                  }
                  else
                  {
                      Response.Redirect("erreur.aspx", true);
                  }
              }   
             
          }}
          

          but he dosen't work correctly, i detect that "Request.Headers["X-Wap-Profile"] != null" is null, i testing from a pda hp and o mobile

          B Offline
          B Offline
          Bernhard Hiller
          wrote on last edited by
          #4

          Are you sure that Request.Headers["X-Wap-Profile"] returns null, when X-Wap-Profile is not set? Actually, we could expect it to do so, but I'd prefer to include an empty string as a possible return value. Hence, replace

          if (Request.Headers["X-Wap-Profile"] != null)

          by

          if (!string.IsNullOrEmpty(Request.Headers["X-Wap-Profile"]))

          T 1 Reply Last reply
          0
          • B Bernhard Hiller

            Are you sure that Request.Headers["X-Wap-Profile"] returns null, when X-Wap-Profile is not set? Actually, we could expect it to do so, but I'd prefer to include an empty string as a possible return value. Hence, replace

            if (Request.Headers["X-Wap-Profile"] != null)

            by

            if (!string.IsNullOrEmpty(Request.Headers["X-Wap-Profile"]))

            T Offline
            T Offline
            tek 2009
            wrote on last edited by
            #5

            thinks for your reply. yes i'm sure that returns null , and also your proposition returns null, this is the code used in my form load:

            bool IsMobi = false;

            // If request header can find the X-Wap-Profile, then it is a mobile browser
            if (!string.IsNullOrEmpty(Request.Headers["X-Wap-Profile"]))
            {
            if (Request.Headers["X-Wap-Profile"].ToString().Length > 0)
            {
            IsMobi = true;
            Response.Redirect("erreur.aspx", true);
            }
            else
            {
            Response.Redirect("login.aspx", true);
            }
            } }

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups