Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 共享Windows托管服务器上托管的ASP.NET Web API应用程序的Google API调用失败_C#_Asp.net_.net_Asp.net Web Api2_Shared Hosting - Fatal编程技术网

C# 共享Windows托管服务器上托管的ASP.NET Web API应用程序的Google API调用失败

C# 共享Windows托管服务器上托管的ASP.NET Web API应用程序的Google API调用失败,c#,asp.net,.net,asp.net-web-api2,shared-hosting,C#,Asp.net,.net,Asp.net Web Api2,Shared Hosting,我已经创建了一个ASP.net Web API应用程序。这个应用程序有一个API,它从我的Android应用程序接收sku Id和购买令牌,验证购买并返回适当的结果。现在的问题是,当我在本地运行我的应用程序时,它运行良好。谷歌给我回复,我可以处理。但是,当我在共享Windows托管服务器上托管此应用程序时,此调用失败。它只是失败了,没有错误 这是我的Web API [HttpPost] [Route("Api/Files/GetFiles")] public HttpResponseMessag

我已经创建了一个ASP.net Web API应用程序。这个应用程序有一个API,它从我的Android应用程序接收sku Id和购买令牌,验证购买并返回适当的结果。现在的问题是,当我在本地运行我的应用程序时,它运行良好。谷歌给我回复,我可以处理。但是,当我在共享Windows托管服务器上托管此应用程序时,此调用失败。它只是失败了,没有错误

这是我的Web API

[HttpPost]
[Route("Api/Files/GetFiles")]
public HttpResponseMessage GetFiles(FileInfo fileInfo)
{
    string skuId = fileInfo.SkuId;
    string purchaseToken = fileInfo.PurchaseToken;
    ProductPurchase productPurchase = GoogleAPIConnector.GetProductPurchaseInfo(skuId, purchaseToken);
}
下面是“GetProductPurchaseInfo”函数

public static ProductPurchase GetProductPurchaseInfo(string productId, string purchaseToken)
        {
            string packageName = "my.package.name";

            string sFileContents = "my p12 file contents as a byte array";

            byte[] baFileContents = Convert.FromBase64String(sFileContents);

            var certificate = new X509Certificate2(baFileContents,
                            "notasecret",
                            X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet
                        );

            var credentials = new ServiceAccountCredential(
                    new ServiceAccountCredential.Initializer("my publisher account on google play service")
                    {
                        Scopes = new[] { AndroidPublisherService.Scope.Androidpublisher }
                    }.FromCertificate(certificate));

            var service = new AndroidPublisherService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credentials,
                ApplicationName = "my application name",
            });

            return service.Purchases.Products.Get(packageName, productId, purchaseToken).Execute();
        }

我绞尽脑汁想找到解决办法。这可能是因为共享主机环境中禁止API调用吗?我认为这可能是唯一的原因,因为当应用程序在本地运行时,调用是成功的。或者我缺少服务器上的某些配置?

我可以通过更改我的web主机提供商来解决此问题。我选择了Accuwebhosting。我部署了我的代码,使用Postman调用了API,并且能够得到响应


所以,这是戈达迪的错。(还有一个讨厌它们的理由?

“它只是失败了,没有错误。”-它怎么能失败而没有错误呢?没有提出例外情况吗?您是否在任何地方有异常处理程序或日志记录?@Dai:对GetProductPurchaseInfo的调用放在try-catch块中。并且正在记录异常。作为另一项措施,我正在编写两条日志消息——一条在调用GetProductPurchaseInfo之前,一条在调用GetProductPurchaseInfo之后。我只能看到日志文件中的第一条消息。这意味着service.Purchases.Products.Get(packageName、productId、purchaseToken).Execute()永远不会返回。那么,google api有任何IP限制吗?@Canela:我不知道。我已经问过他们很多次了,但是Godaddy著名的客户服务团队没有给我一个明确的答案。但这似乎是一个共同的主题。见这个问题: