Cognitive Face API返回Web应用程序没有结果 [英] Cognitive Face API returning No result from Web Application

查看:62
本文介绍了Cognitive Face API返回Web应用程序没有结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Team,

我正在使用Microsoft Cognitive Face API实现人脸检测以验证此人并登录该应用程序。

I am using the Microsoft Cognitive Face API for implementing the Face Detection to Authenticate the person and login to the application.

为此,我正在创建一个PersonGroup并添加Person,然后添加Person of Face。培训人员小组等。

For that, I am creating a PersonGroup and add the Person and then Face of Person. Train Person group and so on.

我为此创建了一个WPF应用程序,一切正常。但实际的要求是我想在MVC Web应用程序中实现它。我在MVC Web应用程序中编写了相同的代码。

I have created a WPF application for this and everything works fine there. But the actual requirement is that I want to implement it in MVC Web Application. I have written the same code in MVC Web Application.

但是API没有返回任何内容而只是挂在Http请求调用上。这是我写的代码。

But there API is not returning anything and just hanged at the Http request call. Here is the code what I have written.

public class HttpClientHelper
    {
        HttpClient httpClient = new HttpClient();

        private const string subscriptionKey = "XXXXXXXXXXXXXXXXXXXXXXXXXX";

        private const string faceEndpoint = "https://southeastasia.api.cognitive.microsoft.com/face/v1.0/";

        public HttpClientHelper()
        {
            httpClient.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
            httpClient.BaseAddress = new Uri(faceEndpoint);
        }

        public async Task<T> GetAsync<T>(string url)
        {
            var response = await httpClient.GetAsync(url);
            string contentString = await response.Content.ReadAsStringAsync();
            return JsonConvert.DeserializeObject<T>(contentString);
        }
    }


public static async Task CreatePersonGroup(UserGroup userGroup)
        {
            bool isGroupExists = false;
            PersonGroup personGroup;

            try
            {
                HttpClientHelper httpClientHelper = new HttpClientHelper();
                var response = httpClientHelper.GetAsync<PersonGroup>(string.Format("persongroups/{0}", userGroup.UserGroupId)).Result;

                personGroup = await faceClient.PersonGroup.GetAsync(userGroup.UserGroupId);
                userGroup.UserGroupId = personGroup.PersonGroupId;
                isGroupExists = true;
            }
            catch (APIErrorException ex)
            {
                if (ex.Body.Error.Code == "PersonGroupNotFound")
                    isGroupExists = false;
            }

            if (isGroupExists == false)
            {
                await faceClient.PersonGroup.CreateAsync(userGroup.UserGroupId, userGroup.Name);
            }
        }




它只是挂在httpClient上。 GetAsync()方法调用并没有提前。而相同的东西在控制台应用程序和WPF应用程序中完全正常。 

It just gets hanged at httpClient.GetAsync() method call and does not move ahead. Whereas the same stuff works perfectly fine in a Console application and WPF Application. 

请帮助我。 

Kindly do help me. 

仅用于更新,当我从Web应用程序进行调用并在"度量标准"下监视它时在Azure门户中可用。它显示了"客户端错误"下的计数。当我从控制台应用程序拨打电话时,它会转到"成功
通话"。

Just For an update, When I am making a call from Web Application and Monitor it under "Metrics" available in Azure portal. It shows me the count under "Client Errors". And When I make a call from Console Application it goes to "Successful Calls".

那么请你帮我一下我该怎么办?检查此客户端错误是什么?如何获得有关此客户端错误的更多详细信息?

So can you please help me how can I check what this Client Error is? And How Can I get more details about this Client Error?

推荐答案

Hi Dipen,

Hi Dipen,

很抱歉听到您患有这种"无回应"错误,w 我想在这个问题上与你进一步合作。您能否发送电子邮件至azcommunity@microsoft.com与我们联系?请向我们提供您的订阅ID和此线程的URL

Sorry to hear you are suffering from this kind of "No response" error, we'd like to work with you further on this issue. Can you please email us at azcommunity@microsoft.com? Please provide us with your subscription ID and the URL for this thread.

问候,

宇通

------------------------------- -------------------------------------------------- --------------------------
$
如果您发现这篇文章有用,请给它一个"有用"的投票。

如果有帮助,请记得将回复标记为答案。


这篇关于Cognitive Face API返回Web应用程序没有结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆