The remote name could not be resolved: 'graph.microsoft.com' Proxy IIS

Viewed 1179

I have implemented an Azure Active directory app using Microsoft Graph API. It works very well as expected in the Local Dev machine which works on IIS express.

Now I want to move the web to IIS and when deployed the WebRequest which talks to graph.microsoft.com throws an exception:

The remote name could not be resolved: 'graph.microsoft.com' at System.Net.HttpWebRequest.GetResponse() at

As I am behind the corporate proxy, I am routing the request throe below means.

In the code..

1st way:

IWebProxy webProxy = new WebProxy("http://{proxy url}:8080", true);
webProxy.Credentials = CredentialCache.DefaultCredentials;
request.Proxy = webProxy; 

2nd way:

IWebProxy webProxy = WebRequest.GetSystemWebProxy();
request.Proxy = webProxy;

request.Method = "GET";
request.Accept = "application/json";
request.Headers.Add("Authorization", "Bearer " + token);

var response = request.GetResponse();
using(var reader = new StreamReader(response.GetResponseStream()))
{
    responseContent = reader.ReadToEnd();
}

I have placed the below proxy configuration in the web.conig:

<system.net>
    <defaultProxy>
        <proxy usesystemdefault="True" 
               proxyaddress="http://{proxy url}:8080" 
               bypassonlocal="True"></proxy>
    </defaultProxy>
</system.net>

Nothing works and I continue to get the exception The remote name could not be resolved:'graph.microsoft.com'

0 Answers
Related