HOW TO
Authentication tokens can be stored and re-used until they expire, as specified by their timeout value. This article details one way to handle tokens in a .NET environment.
Code:
Public Sub refreshToken(ByVal k As String, ByVal v As Object, ByVal r As System.Web.Caching.CacheItemRemovedReason)
Dim onRemove As System.Web.Caching.CacheItemRemovedCallback = New System.Web.Caching.CacheItemRemovedCallback(AddressOf Me.refreshToken)
Dim authWS As New Auth.Authentication
Dim token As String = authWS.getToken("username", "password")
HttpRuntime.Cache.Insert("AUTHENTICATION_TOKEN", token, Nothing, DateTime.Now.AddMinutes(59), System.Web.Caching.Cache.NoSlidingExpiration, Caching.CacheItemPriority.High, onRemove)
End Sub
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
refreshToken(Nothing, Nothing, Nothing)
End Sub
Code:
Cache.Get("AUTHENTICATION_TOKEN")
Article ID:000008431
Get help from ArcGIS experts
Download the Esri Support App