I was wondering if you can help me on something i need to figure out. I have 2 websites, one is a main website, and the other is a mobile phone website, where users can connect using their mobile phones.
However what i want to do is that if somebody tries to connect to the main website through their mobile phone it re-directs them to the mobile website as the CSS layout of the main website wil not suit users needs if they try to connect using a phone.? can
this be done..?
You can determine if the browser is from mobile client by using HttpContext.Current.Request.Browser.IsMobileDevice now u need to handle the redirection very early so consider putting your logic in your main site globale.ascx
Application_BeginRequest event handler. Do the check and if the it's mobile device make the redirection to your mobile website.
Hope that helps
Mark "answer" if my post helped you find the answer.
"And say: My Lord increase me in knowledge."
Thanks that was really helpful. I had a look around and found the following code:-
if (Request.Browser["IsMobileDevice"]
== "true")
{
Response.Redirect("default.aspx");
}
else
{
Response.Redirect("contact.aspx");
}
I have put this into the page load of my default page of the main website. As people connect to my main website it will redirect them to the mobile website. However this code seems to be connecting me to the contact page and not the default.aspx
page..? If i connect to the website on my laptop it takes me to the contact.aspx page, and if i connect using my mobile device it does the same. How can i fix this?
I think i am getting somewhere. I am using the following code:-
if (Request.Browser["IsMobileDevice"]
== "true" || Request.Browser["Nokia"] ==
"true")
{
Response.Redirect("contact.aspx");
}
When i connect via laptop it takes me to default.aspx which is fine but when i connect with the Nokia N95 it still takes me to default.aspx. So this means it does not recognize the mobile device..? Any ideas
Sorry i dont like altering the web.config file as it has caused me many problems before. Can you please advise me where the code you suggested should go? My web.config is below:-
<?xml
version="1.0"?><!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
billy_111
Member
333 Points
878 Posts
Predicting how users connect
Mar 14, 2009 03:31 AM|LINK
Hey,
I was wondering if you can help me on something i need to figure out. I have 2 websites, one is a main website, and the other is a mobile phone website, where users can connect using their mobile phones.
However what i want to do is that if somebody tries to connect to the main website through their mobile phone it re-directs them to the mobile website as the CSS layout of the main website wil not suit users needs if they try to connect using a phone.? can this be done..?
Much appreciated
billy
IsToFix
Participant
837 Points
133 Posts
Re: Predicting how users connect
Mar 14, 2009 05:35 AM|LINK
You can determine if the browser is from mobile client by using HttpContext.Current.Request.Browser.IsMobileDevice now u need to handle the redirection very early so consider putting your logic in your main site globale.ascx Application_BeginRequest event handler. Do the check and if the it's mobile device make the redirection to your mobile website.
Hope that helps
"And say: My Lord increase me in knowledge."
B/R
Huthaifa Afanah
billy_111
Member
333 Points
878 Posts
Re: Predicting how users connect
Mar 14, 2009 12:36 PM|LINK
Hey,
Thanks that was really helpful. I had a look around and found the following code:-
I have put this into the page load of my default page of the main website. As people connect to my main website it will redirect them to the mobile website. However this code seems to be connecting me to the contact page and not the default.aspx page..? If i connect to the website on my laptop it takes me to the contact.aspx page, and if i connect using my mobile device it does the same. How can i fix this?
Thanks
SKT_01
Participant
1930 Points
435 Posts
Re: Predicting how users connect
Mar 14, 2009 02:36 PM|LINK
Hello,
which device are you using? Probably you have to define your phone as mobile device.
billy_111
Member
333 Points
878 Posts
Re: Predicting how users connect
Mar 14, 2009 02:38 PM|LINK
Thanks for replying. The phone i am using is Nokia n95, but i want the code to work with every mobile device, so how can i do this?
IsToFix
Participant
837 Points
133 Posts
Re: Predicting how users connect
Mar 14, 2009 02:51 PM|LINK
Some mobile device does not introduce themselves as mobiles. Anyway check this link http://forums.asp.net/p/1024393/1392672.aspx
"And say: My Lord increase me in knowledge."
B/R
Huthaifa Afanah
SKT_01
Participant
1930 Points
435 Posts
Re: Predicting how users connect
Mar 14, 2009 02:57 PM|LINK
Hello,
Paste the following code in the browserCaps section of the Web.config of your application.
<filter> <case match="Series60/(?'version'\d+\.\d+)"> browser = "S60" version = ${version} IsMobileDevice = true </case> </filter>then you have to define all mobile devices and to hire a developer team to do this.
billy_111
Member
333 Points
878 Posts
Re: Predicting how users connect
Mar 14, 2009 03:08 PM|LINK
Hey,
I think i am getting somewhere. I am using the following code:-
When i connect via laptop it takes me to default.aspx which is fine but when i connect with the Nokia N95 it still takes me to default.aspx. So this means it does not recognize the mobile device..? Any ideas
Thanks
SKT_01
Participant
1930 Points
435 Posts
Re: Predicting how users connect
Mar 14, 2009 03:12 PM|LINK
Hello,
I just wrote you how to define the Nokia N95.
billy_111
Member
333 Points
878 Posts
Re: Predicting how users connect
Mar 14, 2009 03:17 PM|LINK
Sorry i dont like altering the web.config file as it has caused me many problems before. Can you please advise me where the code you suggested should go? My web.config is below:-