elastic / apm-agent-dotnet

https://www.elastic.co/guide/en/apm/agent/dotnet/current/index.html
Apache License 2.0
586 stars 208 forks source link

Do not read claims from SqlRoleProvider under classic ASP.NET #2377

Closed Mpdreamz closed 5 months ago

Mpdreamz commented 5 months ago

Otherwise SqlRoleProvider potentially tries to ensure a local database is created to provide

[2024-06-13 12:41:39.959 +08:00][55][Error] - {ElasticApmModule.#4} Processing EndRequest event failed +-> Exception: System.Web.HttpException: Unable to connect to SQL Server database.
   at System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir, String connectionString)
   at System.Web.DataAccess.SqlConnectionHelper.EnsureDBFile(String connectionString)
   at System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation)
   at System.Web.Security.SqlRoleProvider.GetRolesForUser(String username)
   at System.Web.Security.RolePrincipal.GetRoles()
   at System.Web.Security.RoleClaimProvider.<get_Claims>d__4.MoveNext()
   at System.Security.Claims.ClaimsIdentity.<get_Claims>d__51.MoveNext()
   at System.Security.Claims.ClaimsPrincipal.<get_Claims>d__37.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Elastic.Apm.AspNetFullFramework.ElasticApmModule.<FillSampledTransactionContextUser>g__GetClaimWithFallbackValue|32_0(ClaimsPrincipal principal, String claimType, String fallbackClaimType)
   at Elastic.Apm.AspNetFullFramework.ElasticApmModule.FillSampledTransactionContextUser(HttpContext context, ITransaction transaction)
   at Elastic.Apm.AspNetFullFramework.ElasticApmModule.ProcessEndRequest(Object sender)
   at Elastic.Apm.AspNetFullFramework.ElasticApmModule.OnEndRequest(Object sender, EventArgs e)