Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / WebException.cs / 1 / WebException.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Net {
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
/*++
Abstract:
Contains the defintion for the WebException object. This is a subclass of
Exception that contains a WebExceptionStatus and possible a reference to a
WebResponse.
--*/
///
///
/// Provides network communication exceptions to the application.
///
/// This is the exception that is thrown by WebRequests when something untoward
/// happens. It's a subclass of WebException that contains a WebExceptionStatus and possibly
/// a reference to a WebResponse. The WebResponse is only present if we actually
/// have a response from the remote server.
///
///
[Serializable]
public class WebException : InvalidOperationException, ISerializable {
private WebExceptionStatus m_Status = WebExceptionStatus.UnknownError; //Should be changed to GeneralFailure;
private WebResponse m_Response;
[NonSerialized]
private WebExceptionInternalStatus m_InternalStatus = WebExceptionInternalStatus.RequestFatal;
///
///
/// Creates a new instance of the
/// class with the default status
/// from the
/// values.
///
///
public WebException() {
}
///
///
/// Creates a new instance of the class with the specified error
/// message.
///
///
public WebException(string message) : this(message, null) {
}
///
///
/// Creates a new instance of the class with the specified error
/// message and nested exception.
///
/// Message - Message string for exception.
/// InnerException - Exception that caused this exception.
///
///
///
public WebException(string message, Exception innerException) :
base(message, innerException) {
}
public WebException(string message, WebExceptionStatus status) :
this(message, null, status, null) {
}
///
///
/// Creates a new instance of the class with the specified error
/// message and status.
///
/// Message - Message string for exception.
/// Status - Network status of exception
///
///
internal WebException(string message, WebExceptionStatus status, WebExceptionInternalStatus internalStatus, Exception innerException) :
this(message, innerException, status, null, internalStatus) {
}
///
///
/// Creates a new instance of the class with the specified error
/// message, nested exception, status and response.
///
/// Message - Message string for exception.
/// InnerException - The exception that caused this one.
/// Status - Network status of exception
/// Response - The WebResponse we have.
///
///
public WebException(string message,
Exception innerException,
WebExceptionStatus status,
WebResponse response) :
this(message, null, innerException, status, response)
{ }
internal WebException(string message, string data, Exception innerException, WebExceptionStatus status, WebResponse response) :
base(message + (data != null ? ": '" + data + "'" : ""), innerException)
{
m_Status = status;
m_Response = response;
}
internal WebException(string message,
Exception innerException,
WebExceptionStatus status,
WebResponse response,
WebExceptionInternalStatus internalStatus) :
this(message, null, innerException, status, response, internalStatus)
{ }
internal WebException(string message, string data, Exception innerException, WebExceptionStatus status, WebResponse response, WebExceptionInternalStatus internalStatus) :
base(message + (data != null ? ": '" + data + "'" : ""), innerException)
{
m_Status = status;
m_Response = response;
m_InternalStatus = internalStatus;
}
protected WebException(SerializationInfo serializationInfo, StreamingContext streamingContext)
: base(serializationInfo, streamingContext) {
// m_Status = (WebExceptionStatus)serializationInfo.GetInt32("Status");
// m_InternalStatus = (WebExceptionInternalStatus)serializationInfo.GetInt32("InternalStatus");
}
///
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
GetObjectData(serializationInfo, streamingContext);
}
[SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)]
public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext){
base.GetObjectData(serializationInfo, streamingContext);
//serializationInfo.AddValue("Status", (int)m_Status, typeof(int));
//serializationInfo.AddValue("InternalStatus", (int)m_InternalStatus, typeof(int));
}
///
///
/// Gets the status of the response.
///
///
public WebExceptionStatus Status {
get {
return m_Status;
}
}
///
///
/// Gets the error message returned from the remote host.
///
///
public WebResponse Response {
get {
return m_Response;
}
}
///
///
/// Gets the error message returned from the remote host.
///
///
internal WebExceptionInternalStatus InternalStatus {
get {
return m_InternalStatus;
}
}
}; // class WebException
internal enum WebExceptionInternalStatus {
RequestFatal = 0,
ServicePointFatal = 1,
Recoverable = 2,
Isolated = 3,
}
} // namespace System.Net
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ContainerAction.cs
- ContractMapping.cs
- WindowsFormsLinkLabel.cs
- ContentControl.cs
- OptimalBreakSession.cs
- ServiceBehaviorElementCollection.cs
- TraceLevelStore.cs
- Rotation3D.cs
- ToolStripProgressBar.cs
- Invariant.cs
- SimpleLine.cs
- MembershipUser.cs
- SolidBrush.cs
- UnmanagedMarshal.cs
- CustomPopupPlacement.cs
- FlowLayoutPanelDesigner.cs
- XsltSettings.cs
- HttpConfigurationContext.cs
- LayoutExceptionEventArgs.cs
- CodeArrayIndexerExpression.cs
- MetadataCacheItem.cs
- ScriptResourceAttribute.cs
- LambdaCompiler.ControlFlow.cs
- FieldAccessException.cs
- RenderingBiasValidation.cs
- DataGridColumn.cs
- serverconfig.cs
- HtmlControlAdapter.cs
- SqlConnectionPoolProviderInfo.cs
- ContainsRowNumberChecker.cs
- StringPropertyBuilder.cs
- DataContractSerializerElement.cs
- X509CertificateCollection.cs
- MiniAssembly.cs
- StylusPointPropertyId.cs
- _UriSyntax.cs
- TableDetailsCollection.cs
- WebBaseEventKeyComparer.cs
- COAUTHINFO.cs
- FontStyleConverter.cs
- FormatSettings.cs
- MouseOverProperty.cs
- DefaultEvaluationContext.cs
- AspNetSynchronizationContext.cs
- Emitter.cs
- PrintControllerWithStatusDialog.cs
- SchemaHelper.cs
- SchemaAttDef.cs
- CodeArrayCreateExpression.cs
- RadioButtonRenderer.cs
- MouseEvent.cs
- WebBrowserSiteBase.cs
- PeerCustomResolverElement.cs
- MaterialCollection.cs
- BookmarkManager.cs
- InputMethodStateTypeInfo.cs
- dsa.cs
- WebPartConnectionsConfigureVerb.cs
- ComplexPropertyEntry.cs
- Message.cs
- BookmarkOptionsHelper.cs
- WorkflowExecutor.cs
- SmiEventSink_Default.cs
- CmsInterop.cs
- BaseResourcesBuildProvider.cs
- DataObjectPastingEventArgs.cs
- EncoderBestFitFallback.cs
- ISessionStateStore.cs
- UdpConstants.cs
- OneOfConst.cs
- safelinkcollection.cs
- WebControl.cs
- ControlAdapter.cs
- MergeFailedEvent.cs
- BinaryCommonClasses.cs
- PropertyGrid.cs
- TaskHelper.cs
- FontStyles.cs
- ButtonFieldBase.cs
- ButtonFlatAdapter.cs
- CustomPopupPlacement.cs
- RemoteTokenFactory.cs
- WebPartTransformerCollection.cs
- UserControlCodeDomTreeGenerator.cs
- LogSwitch.cs
- AssociationSet.cs
- WebPartUserCapability.cs
- Ref.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- WebFaultClientMessageInspector.cs
- TextTreeExtractElementUndoUnit.cs
- DataContext.cs
- XmlDataSourceView.cs
- ObsoleteAttribute.cs
- HttpBrowserCapabilitiesWrapper.cs
- AlternateViewCollection.cs
- FullTextBreakpoint.cs
- XamlReaderConstants.cs
- WebPartVerbsEventArgs.cs
- WindowsFormsHelpers.cs