Reputation: 13574
I got the detection code for C# from http://detectmobilebrowsers.com/. Now, I don't know where to put this up and how to get it working.
Basically, all I want is that my mobile visitors should be redirected to http://m.site.com, where my mobile website resides. Let me know how to achieve this task via above code or any other method.
NOTE:- The main website is an Asp.net MVC3 application.
Upvotes: 1
Views: 2766
Reputation: 1606
I would call the code in the global.asax Application_BeginRequest event.
void Application_BeginRequest(object sender, EventArgs e)
{
string u = Request.ServerVariables["HTTP_USER_AGENT"];
if (BrowserDetect.IsMobile(u)) //Pretend there is class and function that has all the regex stuff here.
{
Response.Redirect("http://m.site.com");
}
}
Upvotes: 4
Reputation: 109
Well you can write an asp.net HTTP Module in your main mvc3 app. In the module handle the BeginRequest event and put your detection code in there. If it's a mobile request then redirect.
Upvotes: 1