Fehler (407) "Proxy-Authentifizierung erforderlich."

Ich habe eine Anforderung wie ... Ich möchte über eine Winform auf eine URL (Anmeldeseite im Web) zugreifen. Ich muss die Anmeldeinformationen an diese URL übergeben und die Antwort sollte der Inhalt der authentifizierten Webseite (Markup) sein.

Ich habe eine Funktion geschrieben, die die URL anfordert und die Antwort zurückgibt. aber ich erhalte den Fehlercode (407)

"Proxy-Authentifizierung erforderlich."

Hier ist mein Code.

private static void GetPageContent(){
    string url = "https://LoginPage.aspx/";
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    request.Method = "GET";
    // If required by the server, set the credentials.
    //request.Proxy.Credentials = CredentialCache.DefaultCredentials;
    request.Credentials = new NetworkCredential("user1", "testuser#");
    // Get the response.
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    // Display the status.
    Console.WriteLine(response.StatusDescription);
    // Get the stream containing content returned by the server.
    Stream dataStream = response.GetResponseStream();
    // Open the stream using a StreamReader for easy access.
    StreamReader reader = new StreamReader(dataStream);
    // Read the content.
    string responseFromServer = reader.ReadToEnd();
    // Display the content.
    Console.WriteLine(responseFromServer);
    // Cleanup the streams and the response.
    reader.Close();
    dataStream.Close();
    response.Close();
}

Antworten auf die Frage(4)

Ihre Antwort auf die Frage