// Get api/user/downloadfileanonymous?id=&token= public async Task <FileContentResult> DownloadFileAnonymous(long id, string token) { try { var user = new JwtSecurityTokenHandler().ValidateToken(token.Replace("Bearer ", ""), AuthOptions.GetTokenValidationParameters(), out SecurityToken _) ?? throw new UnauthorizedAccessException(); return(await _userService.DownloadFile(id, user.GetUserId())); } catch { throw new UnauthorizedAccessException(); } }