Exemple #1
0
        public override IProxy <TContract> GetProxy()
        {
            var httpUserIdentity = ClientIdentity.Create(HttpContext.Current.User.Identity);

            Logger.LogEvent(string.Format("Creating proxy of type {0}, which forwards HttpContext identity. The forwarded identity name is '{1}'.", typeof(TContract).Name, httpUserIdentity.Identity.Name), this, ImportanceLevels.gUnimportant);
            var proxy = GetProxy(httpUserIdentity);

            Logger.LogEvent(string.Format("Proxy of type {0}, which forwards HttpContext identity has been created.", typeof(TContract).Name), this, ImportanceLevels.gUnimportant);
            return(proxy);
        }
Exemple #2
0
        public async Task <Profile?> GetProfileAsync()
        {
            var requestUri = CreateRequestUri("api/profile");
            var identity   = ClientIdentity.Create();

            using var request = new HttpRequestMessage(HttpMethod.Get, requestUri).WithJsonContent(identity);

            using HttpResponseMessage response = await _httpClient.SendAsync(request);

            if (!response.IsSuccessStatusCode)
            {
                throw new HttpRequestException("Failed to get profile information", null, response.StatusCode);
            }

            return(await response.Content.ReadFromJsonAsync <Profile>());
        }