1

I have the following code which works fine when forwarding to my 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;
    }
}

However when I change it to my website on azure (e.g xxxx.azurewebsites.net), it does not work.

Any idea if I need to have a different configuration to Azure? I am assuming that on Azure the port is 80.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
user3362714
  • 159
  • 1
  • 9

1 Answers1

1

I assume you're following this tutorial here : http://blog.kloud.com.au/2013/11/24/do-it-yourself-web-api-proxy/

Check if you have the below entry on your web/app.config

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

Remove the <defaultProxy enabled="false" />

Hugo Hilário
  • 2,848
  • 2
  • 27
  • 43