I'm using the 51degrees API for mobile redirection: http://51degrees.codeplex.com/
When a mobile device is detected, using 51degrees, I am able to redirect from from any desktop page to the mobile homepage using the 51degrees configuration only. I.e. http://www.mydomain.com/somepage to http://m.somepage.com/default.
What I am unable to do is redirect to the same page, i.e. from http://www.mydomain.com/somepage to http://m.somepage.com/somepaage.
Is it possible to redirect to the same page?
Option 1: Use 51degrees for the mobile detection part only and wire up the redirect yourself. Remove the <redirect>
element from your web.config and try something like this in your Global.asax file:
void Application_BeginRequest(object sender, EventArgs e)
{
if (HttpContext.Current.Request.Browser.IsMobileDevice)
{
Response.Redirect("http://m.mydomain.com" + Request.RawUrl);
}
}
Option 2: In the <redirect>
element in the web.config file, add the property originalUrlAsQueryString=true
. This will send a query string called origUrl to the mobile homepage giving you the option to redirect to the mobile version of the requested page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With