There is a code snippet for this
http://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#e2048dba-f235-4eb1-8037-6d838d053c2e...