web mobile application
-
how to restrict access to a web application just for mobile terminals,( not having access from a pc) thinks
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 IfGood luck. :thumbsup:
-
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 IfGood luck. :thumbsup:
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
-
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
Are you sure that
Request.Headers["X-Wap-Profile"]
returnsnull
, whenX-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, replaceif (Request.Headers["X-Wap-Profile"] != null)
by
if (!string.IsNullOrEmpty(Request.Headers["X-Wap-Profile"]))
-
Are you sure that
Request.Headers["X-Wap-Profile"]
returnsnull
, whenX-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, replaceif (Request.Headers["X-Wap-Profile"] != null)
by
if (!string.IsNullOrEmpty(Request.Headers["X-Wap-Profile"]))
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);
}
} }