'ITrackingConsentFeature not working in production
I have a cookie consent banner in my blazor server app, everything works well when building in debug mode, but when I push it into production I get a "Object reference not set to an instance of an object" exception. What can I do to solve this problem
ITrackingConsentFeature consentFeature ;
bool showBanner;
string cookieString;
protected override Task OnAfterRenderAsync(bool firstRender)
{
if(firstRender)
{
consentFeature = hca.HttpContext.Features.Get<ITrackingConsentFeature>();
showBanner = !consentFeature?.CanTrack ?? false;
cookieString = consentFeature?.CreateConsentCookie();
}
return base.OnAfterRenderAsync(firstRender);
}
The issue occurs on the line where we're getting ITrackingConsentFeature
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|