switch between mobile / normal mode

Mar 13, 2012 at 12:46 PM

Hi guys, been using your mobile pack v 1.0 for episerver and been trying to find where / how you switch between mobile / normal modes when on a mobile device?  Seen plenty of chat about it so im presume its possible but not been able to find any information on this.

cheers,

Adam

Developer
Mar 14, 2012 at 8:13 AM

Hi Adam

You have to set a cookie with the name mobileToggle and either give it a value of normal to only show the normal site or mobile to always show the mobile site. If the cookie isn't set or it doesn't have a value regular redirect rules will apply. For some example see mobilepack.js under: modules/MobilePack/mobilepack.js.

Hope this helps

Frederik

Mar 14, 2012 at 9:05 AM

thanks dude, appreciate it.

Mar 27, 2012 at 3:50 PM

Hi Frederik,


Finally got round to implementing this and I cant seem to get it to work.  I have a button that calls a function that performs the following:

HttpCookie toggle;

            if (Request.Cookies["mobileToggle"] != null)
            {
                toggle = Request.Cookies["mobileToggle"];
            }
            else
            {
                toggle = new HttpCookie("mobileToggle");
            }

            toggle.Value = MobileToggle.normal.ToString();
            //toggle.Expires = DateTime.Now.AddMinutes(20);
            Request.Cookies.Set(toggle);

I have output the cookie value on the page and once the button is clicked its value is correctly set to normal (so I shoudl be able to browse the full site). How ever once I redirect to the home page, the mobile redirection is kicking in again, removing that cookie (my output param above is null on returning to this page) and displaying the mobile version?

I tried also setting an artificial time to the cookie expire to make sure that it should be present, but something is definitely removing it, I've search the solution and there are no instances of Request.Cookies.Clear, so thats not happening from the code.

Any ideas on what I have wrong?

Cheers,

Adam

Mar 28, 2012 at 8:52 AM

Not to worry, grabbed the mobile demo and going to use the js method, should have thought of that before!