hi friends,
is it safe to use web.config connection string in background jobs like following or somehow is it possible that this job could not find web.config file under specific conditions. I’m asking because I read that hangfire can run jobs in different processes. I never faced the problem but I need to know. Maybe under heavy load hangfire tries to run my class “out of context” or “out of application” without proper web.config ? I believe its not possible but I need confirmation, please.
best.
I’m calling the job:
BackgroundJob.Enqueue(Sub() HangfireFunctionsClass.myExecute_HF(sqlstr))
and the class is:
Public Class HangfireFunctionsClass
Shared sub myExecute_HF(ByVal sqlstr As String)
' Is the following line is okay in this class (for hangfire of course) ?
dim CONN_STR = System.Configuration.ConfigurationManager.ConnectionStrings("ConnectionStringNET").ConnectionString
Using cn As New SqlConnection(DBClass.ConnectionString_)
cn.Open()
Using cmd As New SqlCommand(sqlstr, cn)
cmd.ExecuteNonQuery()
End Using
end using
End Function
End Class