首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >两个WebAPI之间的Azure WebSites ->调用

两个WebAPI之间的Azure WebSites ->调用
EN

Stack Overflow用户
提问于 2015-01-21 22:00:23
回答 1查看 499关注 0票数 0

我有两个ASP.NET vNext Web应用程序在Azure WebSites上运行CoreCLR,由lates VisualStudio2015CTP发布。当我试图用标准HttpClient代码从一个应用程序调用到另一个应用程序时:

代码语言:javascript
复制
        using (var client = new HttpClient())
        {
            client.BaseAddress = new Uri(_webUri);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HttpContent contentPost = new StringContent(request.ToJson(), Encoding.UTF8, "application/json");
            var response = await client.PostAsync(uri, contentPost);//.PostAsJsonAsync("api/products", request);
            if (response.IsSuccessStatusCode)
            {
                   ...
            }
        }

我得到了以下例外:

代码语言:javascript
复制
WinHttpException: An attempt was made to access a socket in a way forbidden by its access permissions.
   System.Net.Http.WinInetProxyHelper.GetProxyForUrl(SafeInternetHandle sessionHandle, Uri uri, WINHTTP_PROXY_INFO& proxyInfo)

HttpRequestException: An error occurred while sending the request.
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

我的web.config在蔚蓝网站ftp:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="kpm-package-path" value="..\approot\packages" />
    <add key="bootstrapper-version" value="1.0.0-beta2" />
    <add key="kre-package-path" value="..\approot\packages" />
    <add key="kre-version" value="1.0.0-beta2" />
    <add key="kre-clr" value="CoreCLR" />
    <add key="kre-app-base" value="..\approot\src\Ingrid.Web" />
  </appSettings>
</configuration>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-14 02:07:15

我在以下网站找到的解决方案:https://github.com/sendgrid/sendgrid-csharp/issues/18

与RestSharp相比,HttpClient更好,而且它确实在工作:http://restsharp.org/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28077659

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档