22using System . Collections . Generic ;
33using System . Linq ;
44using System . Runtime . Remoting . Messaging ;
5- using System . Text ;
65using System . Collections . Concurrent ;
7- using System . Threading ;
86using System . Threading . Tasks ;
9- using System . Web . Hosting ;
107using StackifyLib . Models ;
118using StackifyLib . Utils ;
129using StackifyLib . Web ;
@@ -135,14 +132,18 @@ public void QueueLogMessage(Models.LogMsg msg)
135132 if ( string . IsNullOrEmpty ( msg . TransID ) )
136133 {
137134 if ( _IsWebApp && System . Web . Hosting . HostingEnvironment . IsHosted
138- && System . Web . HttpContext . Current != null &&
135+ && System . Web . HttpContext . Current != null && System . Web . HttpContext . Current . Handler != null &&
139136 System . Web . HttpContext . Current . Request != null )
140137 {
141138 msg . TransID = System . Web . HttpContext . Current . Request . GetHashCode ( ) . ToString ( ) ;
142139 }
143140
144141 }
145142 }
143+ catch ( System . Web . HttpException ex )
144+ {
145+ StackifyAPILogger . Log ( "Request not available \r \n " + ex . ToString ( ) ) ;
146+ }
146147 catch ( Exception ex )
147148 {
148149 StackifyAPILogger . Log ( "Error figuring out TransID \r \n " + ex . ToString ( ) ) ;
@@ -151,8 +152,9 @@ public void QueueLogMessage(Models.LogMsg msg)
151152
152153
153154 if ( _IsWebApp && System . Web . Hosting . HostingEnvironment . IsHosted
154- && System . Web . HttpContext . Current != null &&
155- System . Web . HttpContext . Current . Request != null )
155+ && System . Web . HttpContext . Current != null
156+ && System . Web . HttpContext . Current . Handler != null
157+ && System . Web . HttpContext . Current . Request != null )
156158 {
157159 var context = System . Web . HttpContext . Current ;
158160
0 commit comments