Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Initialisiert eine neue Instanz der WebException-Klasse.
Namespace: System.Net
Assembly: System (in system.dll)
Syntax
'Declaration
Public Sub New
'Usage
Dim instance As New WebException
public WebException ()
public:
WebException ()
public WebException ()
public function WebException ()
Hinweise
Der Standardkonstruktor initialisiert eine neue Instanz der WebException-Klasse. Die Message-Eigenschaft wird mit einer vom System bereitgestellten Meldung initialisiert, die den Fehler beschreibt. Diese Meldung berücksichtigt die aktuelle Systemkultur. Die InnerException-Eigenschaft und die Response-Eigenschaft werden mit NULL (Nothing in Visual Basic) initialisiert. Die Status-Eigenschaft wird mit RequestCanceled initialisiert.
Beispiel
Im folgenden Beispiel wird eine Standard-WebException ausgelöst.
Try
' A 'Socket' object has been created.
Dim httpSocket As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
' The IPaddress of the unknown uri is resolved using the 'Dns.Resolve' method.
' which leads to the 'SocketException' exception.
Dim hostEntry As IPHostEntry = Dns.Resolve("https://www.contoso.com")
Dim serverAddress As IPAddress = hostEntry.AddressList(0)
Dim endPoint As New IPEndPoint(serverAddress, 80)
httpSocket.Connect(endPoint)
Console.WriteLine("Connection created successfully")
httpSocket.Close()
Catch e As SocketException
Dim exp As [String] = e.Message
' Throw the WebException with no parameters.
Throw New WebException()
End Try
try
{
// A 'Socket' object has been created.
Socket httpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
// The IPaddress of the unknown uri is resolved using the 'Dns.Resolve' method.
IPHostEntry hostEntry = Dns.Resolve("https://www.contoso.com");
IPAddress serverAddress = hostEntry.AddressList[0];
IPEndPoint endPoint = new IPEndPoint(serverAddress, 80);
httpSocket.Connect(endPoint);
Console.WriteLine("Connection created successfully");
httpSocket.Close();
}
catch(SocketException e)
{
String exp = e.Message;
// Throw the WebException with no parameters.
throw new WebException();
}
try
{
// A 'Socket' object has been created.
Socket^ httpSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp );
// The IPaddress of the unknown uri is resolved using the 'Dns::Resolve' method.
IPHostEntry^ hostEntry = Dns::Resolve( "https://www.contoso.com" );
IPAddress^ serverAddress = hostEntry->AddressList[ 0 ];
IPEndPoint^ endPoint = gcnew IPEndPoint( serverAddress, 80 );
httpSocket->Connect( endPoint );
Console::WriteLine( "Connection created successfully" );
httpSocket->Close();
}
catch ( SocketException^ e )
{
String^ exp = e->Message;
// Throw the WebException with no parameters.
throw gcnew WebException;
}
try {
// A 'Socket' object has been created.
Socket httpSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
// The IPaddress of the unknown uri is resolved using the
// 'Dns.Resolve' method.
IPHostEntry hostEntry = Dns.Resolve("https://www.contoso.com");
IPAddress serverAddress = (IPAddress)hostEntry.get_AddressList()
.get_Item(0);
IPEndPoint endPoint = new IPEndPoint(serverAddress, 80);
httpSocket.Connect(endPoint);
Console.WriteLine("Connection created successfully");
httpSocket.Close();
}
catch (SocketException e) {
String exp = e.get_Message();
// Throw the WebException with no parameters.
throw new WebException();
}
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
WebException-Klasse
WebException-Member
System.Net-Namespace