We had published application on Azure with WIF implemented. We also have WebJob associated with that Web Application.
User logs in to the WebApplication, but we are not getting logged-in user details in WebJob.
WebJob is suppose to get User's Details and store in DB and Blob.
Following code in WebJob returns error -
private string GetLoggedinUser()
{
string givenName = string.Empty;
IClaimsPrincipal claimsPrincipal = HttpContext.Current.User as IClaimsPrincipal;
IClaimsIdentity claimsIdentity = claimsPrincipal.Identity as IClaimsIdentity;
if (claimsIdentity != null)
{
givenName = (from c in claimsIdentity.Claims
where c.ClaimType == ClaimTypes.GivenName
select c.Value).Single();
}
return givenName;
}
Above code throws error "object not referenced" i.e. null object error in "HttpContext.Current"