I have a website that detects mobile browsers and loads a different page to said devices. However, when I load the page in the UIWebView in my iphone app, it loads the default page instead of the mobile page. How can I tell the site that I’m a mobile browser?
My site is an ASP.NET site, with the following C# code implemented in each PageName.aspx.cs file for mobile redirecting:
if(Request.Browser["IsMobileDevice"] == "true")
{
Response.Redirect("mResults.aspx");
}
else
{
Response.Redirect("Results.aspx");
}
I believe what you want to do is change the
User-Agentheader for the request. The technique for doing that can be found in this question: Changing the userAgent of NSURLConnection.EDIT:
Actually, I think your problem is that you’re checking if
Request.Browser["IsMobileDevice"]is equal to theString"true". This will never be the case. It should be a boolean value. If you replace yourifcondition with justRequest.Browser["IsMobileDevice"], I think it might work. Like this:Documentation for this value is here: http://msdn.microsoft.com/en-us/library/system.web.configuration.httpcapabilitiesbase.ismobiledevice.aspx.