Determine the device type and set the MS_DEVICE_TYPE variable

The following C# code shows you how to obtain the header information to determine the device type and set the MS_DEVICE_TYPE variable.

string checkPOS5 = (string) ConfigurationSettings.AppSettings[ 
"AllowOnlyPalmOS5orGreater" ]; 
if( null != checkPOS5 ) { 
checkPOS5.ToLower(); 
} 
if( null != checkPOS5 && 0 < checkPOS5.Length && 
''t'' == checkPOS5[0] && 
"PALM_OS".Equals((string)Session[ "MS_DEVICE_TYPE" ] )) {

string[] osv = 
Request.Headers.GetValues( "X-AvantGo-DeviceOSVersion" );

if( null != osv && 0 < osv.Length ) { 
AGLog.Write( AGLog.INFO, 
"start.aspx.cs: AllowOnlyPalmOS5orGreater " + 
(string)Session[ "MS_DEVICE_TYPE" ] + " " + AvantGo.Utils.Base64DecodeString( osv[0] ) ); 
} else { 
AGLog.Write( AGLog.INFO, 
"start.aspx.cs: AllowOnlyPalmOS5orGreater " + 
(string)Session[ "MS_DEVICE_TYPE" ] + 
"\nMissing X-AvantGo-DeviceOSVersion header." ); 
}

bool invalid = true; 
if( null != osv && 0 < osv.Length ) { 
//String POSver = // a test for 5.0.0 
// AvantGo.Utils.Base64DecodeString( "NS4wLjA=" ); 
String POSver = AvantGo.Utils.Base64DecodeString( osv[0] ); 
AGLog.Write( AGLog.INFO, 
"start.aspx.cs: PalmOS version found: " + POSver); 
string [] vers = POSver.Split( ''.'' ); 
short sver = 0; 
if( 1 <= vers.Length ) { 
try { 
sver = System.Convert.ToInt16( vers[0] ); 
} catch( Exception ) { 
} 
} 
if( 5 <= sver ) { 
invalid = false; 
} 
} 
if( invalid ) { 
AGLog.Write( AGLog.WARN, 
"start.aspx.cs: Invalid PalmOS found!" ); 
AGSyncLog.UpdateSyncStatus(syncId,"2000", 
"Invalid Palm OS Version", 
transactionsQueued, 
transactionsProcessed, 
transactionsFailed); 
Response.Redirect( Request.ApplicationPath + 
"/avantgo/invalidclientpage/invaliddeviceos.html" ); 
} 
}

string[] tmpKey = Request.Headers.GetValues("X-AvantGo-Version"); 
if (tmpKey != null) { 
Session["AvantGo-Version"] = tmpKey[0]; 
} else { 
Session["AvantGo-Version"] = "10.10.1000"; 
}