Share via


WebErrorStatus Enumerazione

Definizione

Definisce gli errori rilevati durante le operazioni relative ai servizi Web, ad esempio l'autenticazione, la configurazione del proxy e gli URI di destinazione.

public enum class WebErrorStatus
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
enum class WebErrorStatus
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public enum WebErrorStatus
var value = Windows.Web.WebErrorStatus.unknown
Public Enum WebErrorStatus
Ereditarietà
WebErrorStatus
Attributi

Requisiti Windows

Famiglia di dispositivi
Windows 10 (è stato introdotto in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (è stato introdotto in v1.0)

Campi

BadGateway 502

Il server fungeva da gateway o proxy e riceveva una risposta non valida dal server upstream.

BadRequest 400

La richiesta non può essere soddisfatta a causa di una sintassi non valida.

CannotConnect 14

Impossibile connettersi alla destinazione.

CertificateCommonNameIsIncorrect 1

Il nome comune del certificato SSL non corrisponde all'indirizzo Web.

CertificateContainsErrors 3

Il certificato SSL contiene errori.

CertificateExpired 2

Il certificato SSL è scaduto.

CertificateIsInvalid 5

Il certificato SSL non è valido.

CertificateRevoked 4

Il certificato SSL è stato revocato.

Conflict 409

Indica che la richiesta non è stata elaborata a causa di un conflitto nella richiesta.

ConnectionAborted 9

La connessione è stata interrotta.

ConnectionReset 10

La connessione è stata reimpostata.

Disconnected 11

La connessione è stata terminata.

ErrorHttpInvalidServerResponse 8

Il server ha restituito una risposta non valida o non riconosciuta.

ExpectationFailed 417

Il server non può soddisfare i requisiti del campo Expect request-header .The server cannot meet the requirements of the Expect request-header field.

Forbidden 403

Il server ha rifiutato la richiesta.

Found 302

La risorsa è stata trovata ma è disponibile in una posizione diversa da quella inclusa nella richiesta.

GatewayTimeout 504

Il server fungeva da gateway o proxy e non riceveva una risposta tempestiva dal server upstream.

Gone 410

Indica che la risorsa richiesta non è più disponibile e non sarà più disponibile.

HostNameNotResolved 15

Impossibile risolvere il nome host specificato.

HttpsToHttpOnRedirection 13

Reindirizzato da una posizione sicura a una posizione non protetta.

HttpToHttpsOnRedirection 12

Reindirizzato da una posizione a una posizione sicura.

HttpVersionNotSupported 505

Il server non supporta la versione del protocollo HTTP usata nella richiesta.

InsufficientRangeSupport 22

La richiesta non supporta l'intervallo.

InternalServerError 500

Messaggio di errore generico, specificato quando non è appropriato alcun messaggio più specifico.

LengthRequired 411

La richiesta non ha specificato la lunghezza del contenuto richiesto dalla risorsa richiesta.

MethodNotAllowed 405

Una richiesta è stata effettuata da una risorsa usando un metodo di richiesta non supportato da tale risorsa.

MissingContentLengthSupport 23

La richiesta ha erroneamente le dimensioni del file.

MovedPermanently 301

Questa e tutte le richieste future devono essere indirizzate all'URI specificato.

MultipleChoices 300

L'URL richiesto rappresenta un raggruppamento generale di cui è necessario effettuare selezioni di livello inferiore.

NotAcceptable 406

La risorsa richiesta è in grado di generare solo contenuto non accettabile in base alle intestazioni Accept inviate nella richiesta.

NotFound 404

Impossibile trovare la risorsa richiesta, ma potrebbe essere nuovamente disponibile in futuro.

NotImplemented 501

Il server non riconosce il metodo di richiesta o non ha la possibilità di soddisfare la richiesta.

NotModified 304

Indica che la risorsa non è stata modificata dall'ultima richiesta.

OperationCanceled 16

L'operazione è stata annullata.

PaymentRequired 402

Riservato.

PreconditionFailed 412

Il server non soddisfa una delle precondizioni che il richiedente ha inserito nella richiesta.

ProxyAuthenticationRequired 407

Il client deve prima autenticarsi con il proxy.

RedirectFailed 17

Il reindirizzamento della richiesta non è riuscito.

RequestedRangeNotSatisfiable 416

Il client ha richiesto una parte del file, ma il server non può fornire tale parte.

RequestEntityTooLarge 413

La richiesta è maggiore di quella del server disposta o in grado di elaborare.

RequestTimeout 408

Timeout del server durante l'attesa della richiesta.

RequestUriTooLong 414

La lunghezza dell'URI specificata supera la lunghezza massima che il server può elaborare.

SeeOther 303

La risposta alla richiesta è disponibile in un altro URI usando un metodo GET.

ServerUnreachable 6

Il server non risponde.

ServiceUnavailable 503

Il server non è attualmente disponibile.

TemporaryRedirect 307

La risorsa richiesta risiede temporaneamente in un URI diverso.

Timeout 7

Timeout della connessione.

Unauthorized 401

L'autenticazione non è riuscita o le credenziali non sono ancora state fornite.

UnexpectedClientError 20

Si è verificato un errore sul lato client imprevisto.

UnexpectedRedirection 19

Una richiesta è stata reindirizzata in modo imprevisto.

UnexpectedServerError 21

Si è verificato un errore imprevisto sul lato server.

UnexpectedStatusCode 18

Codice di stato imprevisto che indica che è stato ricevuto un errore.

Unknown 0

Si è verificato un errore sconosciuto.

UnsupportedMediaType 415

L'entità richiesta ha un tipo di supporto che il server o la risorsa non supporta.

UseProxy 305

È necessario accedere alla risorsa richiesta tramite il proxy specificato dal campo Località.

Commenti

Un valore WebErrorStatus viene restituito da Windows.Web.WebError.GetStatus, Windows.Networking.WebSocketError.GetStatus e Windows.Networking.BackgroundTransfer.GetStatus.

In questo esempio viene illustrato come usare WebErrorStatus per visualizzare un messaggio di errore diverso a seconda del tipo di errore. In questo esempio il valore WebErrorStatus viene restituito da Windows.Networking.WebSocketError.GetStatus.

using Windows.Web;
using Windows.Networking.Sockets;

// Pointer back to the main page. Needed to call methods in MainPage such as NotifyUser()
MainPage rootPage = MainPage.Current;

WebErrorStatus status = WebSocketError.GetStatus(ex.GetBaseException().HResult);

if (status == WebErrorStatus.CannotConnect ||
    status == WebErrorStatus.NotFound || 
    status == WebErrorStatus.RequestTimeout)
{
    rootPage.NotifyUser("Cannot connect to the server", NotifyType.ErrorMessage);
}
else
{
    rootPage.NotifyUser("Error: " + status, NotifyType.ErrorMessage);
}
// Pointer back to the main page. Needed to call methods in MainPage such as NotifyUser().
m_rootPage = MainPage::Current();

Windows::Web::WebErrorStatus status{ Windows::Networking::Sockets::WebSocketError::GetStatus(exception.to_abi()) };

if (status == Windows::Web::WebErrorStatus::CannotConnect ||
    status == Windows::Web::WebErrorStatus::NotFound ||
    status == Windows::Web::WebErrorStatus::RequestTimeout)
{
    m_rootPage.NotifyUser(L"Cannot connect to the server", NotifyType::ErrorMessage);
}
else
{
    m_rootPage.NotifyUser(std::wstring(L"Error: ") + exception.message().c_str(), NotifyType::ErrorMessage);
}
using namespace Windows::Web;
using namespace Windows::Networking::Sockets;

// Pointer back to the main page. Needed to call methods in MainPage such as NotifyUser()
rootPage = MainPage::Current;

WebErrorStatus status = WebSocketError::GetStatus(exception->HResult);

if (status == WebErrorStatus::CannotConnect || 
    status == WebErrorStatus::NotFound || 
    status == WebErrorStatus::RequestTimeout)
{
    rootPage->NotifyUser("Cannot connect to the server", NotifyType::ErrorMessage);
}
else
{
    rootPage->NotifyUser("Error: " + status.ToString(), NotifyType::ErrorMessage);
}

Cronologia delle versioni

Versione di Windows Versione dell'SDK Valore aggiunto
1709 16299 InsufficientRangeSupport
1709 16299 MissingContentLengthSupport

Si applica a

Vedi anche