1

我有以下代码在转发到我时可以正常工作localhost:1671

protected override async System.Threading.Tasks.Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
{
    UriBuilder forwardUri = new UriBuilder(request.RequestUri);
    //remove the proxy port and replace with an Http port
    forwardUri.Port = 1671;
    //send it on to the requested URL
    request.RequestUri = forwardUri.Uri;
    HttpClient client = new HttpClient();
    if (request.Method == HttpMethod.Get)
        request.Content = null;
    try
    {

        var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
        if (response.StatusCode == HttpStatusCode.OK)
        {
            ManageOnline(response.RequestMessage);
        }
        return response;
    }
    catch (Exception ex)
    {
        throw;
    }
}

但是,当我将其更改为我在 azure 上的网站(例如 xxxx.azurewebsites.net)时,它不起作用。

知道我是否需要对 Azure 进行不同的配置吗?我假设在 Azure 上的端口是 80。

4

1 回答 1

1

我假设您在这里学习本教程:http ://blog.kloud.com.au/2013/11/24/do-it-yourself-web-api-proxy/

检查您的web/app.config上是否有以下条目

<system.net>
    <defaultProxy enabled="false" />
</system.net>

去除<defaultProxy enabled="false" />

于 2015-01-19T10:27:40.527 回答