All you need to do is set a querystring parameter on the redirect to the desktop site of nomo=1. This will set 2 cookies, one of which is "disableredirectpresist" which expires after 20mins. If the user stays on the desktop site, this cookie is refreshed by 20mins to keep user on desktop site.
So if you have a link on the desktop site that redirects back to mobile, you would want to delete this cookie from your code behind (can't delete from javascript as its a http cookie).