Cette documentation est archivée et n’est pas conservée.

RequestContext, classe

Provides a reply that is correlated to an incoming request.

Espace de noms: System.ServiceModel.Channels
Assembly : System.ServiceModel (dans system.servicemodel.dll)

public abstract class RequestContext : IDisposable
public abstract class RequestContext implements IDisposable
public abstract class RequestContext implements IDisposable
Non applicable.

You get a request context from an IReplyChannel. Each RequestContext encapsulates the information required to reply to the request, so that you do not have to block on the channel when waiting for each request message to receive a reply.

In the request/reply model, the RequestContext object is the link between the request that comes in and the reply that goes out. When the server receives a request, it provides a RequestContext instance that represents the request to the channel. The request context contains the original request message among other useful properties. This request context is then stashed inside the OperationContext for retrieval by your service. You typically use the Current property to access the request of the current operation.

The value of the RequestContext can be référence Null (Nothing en Visual Basic). Because the role of the request context is to link requests to replies, it does not make sense to have a request context when you do not have a reply, and so in this case the context is set to référence Null (Nothing en Visual Basic). For a one-way operation on top of the request/reply model, the server receives requests but does not send back a response to the client. So if the RequestContext is référence Null (Nothing en Visual Basic) unexpectedly, check first whether the operation contract is IsOneWay.

Special note for MC++ users deriving from this class:

  • Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor.

  • Avoid destructors: they cause the compiler to auto-generate IDiposable

  • Avoid non-reference members: they can cause the compiler to auto-generate IDiposable

  • Avoid finalizers; but if you include one, you should suppress the build warning and call SuppressFinalize and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated IDiposable behavior.


Les membres statiques publics (Shared en Visual Basic) de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile pour Pocket PC, Windows Mobile pour Smartphone, Windows Server 2003, Windows XP Édition Media Center, Windows XP Professionnel Édition x64, Windows XP SP2, Windows XP Starter Edition

Microsoft .NET Framework 3.0 est pris en charge sur Windows Vista, Microsoft Windows XP SP2 et Windows Server 2003 SP1.

.NET Framework

Prise en charge dans : 3.0