No user-agent for anonymous users?

0
Why is there no user-agent information available for anonymous users when calling: getContext().getSession().getUserAgent(); in a java action? When calling this method prior to logging in, a context and session are available however the user-agent information is not. I don't understand why, as a http service request has been made to the server. Resulting in the login page being displayed. So why is this information not available? After logging in the method works as expected.  I would like to display a browser not supported message, when people are using an outdated (non-supported browser). I know there is the Browser-update.org widget that provides such a feature. However this is outdated and doesn't support Chrome configuration. Besides I want to be able to have the browser versions configurable by an administrator instead of having to modify the code/widget settings. So any suggestions how to achieve this are also welcome. 
asked
1 answers
0

I think you cannot get the UserAgent correctly from the session directly. I have your wish functionally working using the following setup.

If you create a JAVA action with the Session as input parameter and you call it using the $currentSession variable, this Java should work:

		// BEGIN USER CODE
		IContext ctx = SessionParameter1.getContext();
		Optional<IMxRuntimeRequest> orreq = ctx.getRuntimeRequest();
		Optional<IMxRuntimeResponse> orres = ctx.getRuntimeResponse();
		String UserAgent = null;
		if (orreq.isPresent()) {

		    IMxRuntimeRequest rr = orreq.get();
		    UserAgent = rr.getHeader("User-Agent");	    
		}
		return UserAgent;
		// END USER CODE

 

answered