Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Ich hab folgenden Code


HttpWebRequest WebRequest = (HttpWebRequest)HttpWebRequest.Create(UriBuilder.Uri);
if (WebRequest != null)
{
WebRequest.Credentials = CredentialCache.DefaultCredentials;
try
{
HttpWebResponse WebResponse = (HttpWebResponse)WebRequest.GetResponse();
if (WebResponse != null)
{
...
}
}
catch (Exception) { }
}
[/PHP]

Wenn die Url des Requests auf eine Adresse außerhalb des lokalen Netzwerks verweist, also über den Proxyserver gehen muss bekomme ich beim GetResponse Aufruf immer die Exception das eine Proxy Authentifizierung erforderlich ist.

Allerdings sollte das doch über die DefaultCredentials bzw. DefaultNetworkCredentials abgedeckt sein. Warum kommt trotzdem diese Exception?

Hi Guybrush,

du musst dem Request bzw. dem Respnse auch noch den Proxy mitgeben.

hir mal ien paar schnipsel aus einer KLasse die ich mir für sowas gtebaut habe


System.Net.WebRequest req = System.Net.WebRequest.Create(this.URL);

				if (!(this.PROXY.Equals("")))

				{

					WebProxy proxyObject = new WebProxy(this.PROXY);

					proxyObject.Credentials=System.Net.CredentialCache.DefaultCredentials;//

					req.Proxy = proxyObject;

				}

				WebResponse response = req.GetResponse(); 

				StreamReader reader = new StreamReader(response.GetResponseStream()); 

				string str = reader.ReadLine();

				while(str != null)

				{

					Console.WriteLine(str);

					str = reader.ReadLine();

				}

jap nur wir haben bei uns z.b. mehrere proxys für mehre netze somit ist die übernahem der std nicht möglich da dort ein script eingebunden ist.

Wenn die Url des Requests auf eine Adresse außerhalb des lokalen Netzwerks verweist, also über den Proxyserver gehen muss bekomme ich beim GetResponse Aufruf immer die Exception das eine Proxy Authentifizierung erforderlich ist.

Allerdings sollte das doch über die DefaultCredentials bzw. DefaultNetworkCredentials abgedeckt sein. Warum kommt trotzdem diese Exception?

Weil die DefaultCredentials deine Windows Authentifizierung darstellen. Wenn dein Rechner Teil eines Active Directorys ist wird also dein Windows Anmeldename als Authentifizierung verwenden.

Über deinen Proxy kommst du evtl noch, auf lokale Intranetserver sowieso, aber die Gegenseite (externer Server) wird dich nicht kennen, deswegen solltest du eine User/Password Authentifizierung anstelle der Default verwenden.

Und bloß nicht das Passwort im Source speichern.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.