سؤال

In a nutshell, I'm trying to figure out how to programmatically enable and disable the redirection for mobile phones, based on a session value, on a per request basis (not statically for everyone).

Here's the back story:

I'm currently using 51Degrees in my ASP.NET application to redirect requests to the mobile version of the site. I would like to add a feature where users can enable and disable this redirection from a "Settings" page. The setting will be different for each user, and so far every setting I've found to disable 51Degrees is static. This makes it difficult to disable it for a subset of users.

One semi-solution I had was to set firstRequestOnly="true" and reverse the redirect if it wasn't supposed to happen. Although firstRequestOnly="true" has caused a number of other headaches (unrelated) so I would like to keep it at firstRequestOnly="false" and simply enable/disable the redirection based on a session value per request, or per user. The problem is that I can't figure out a clean way to do this.

هل كانت مفيدة؟

المحلول

Set the cookie in the page prerender event based on the setting your user has choosen in their profile. You would need to have firstRequestOnly set to true. If the user does not want redirection it should have a very long expiry time, if they do then set a short expiry time.

نصائح أخرى

I ended up just downloading the source code and adding in an option to opt-out of the redirect if a certain session field was present and set to true. This allowed me to set that session value from my code depending on what the user had setup in the settings section. Not the best solution since it's going to be more difficult to upgrade 51Degrees down the road, but it works.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top