RequestContext Class
TOC
Collapse the table of content
Expand the table of content

RequestContext Class

 

Provides a reply that is correlated to an incoming request.

Namespace:   System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

System.Object
  System.ServiceModel.Channels.RequestContext

public abstract class RequestContext : IDisposable

NameDescription
System_CAPS_protmethodRequestContext()

Initializes a new instance of the RequestContext class.

NameDescription
System_CAPS_pubpropertyRequestMessage

When overridden in a derived class, gets the message that contains the request.

NameDescription
System_CAPS_pubmethodAbort()

When overridden in a derived class, aborts processing the request associated with the context.

System_CAPS_pubmethodBeginReply(Message, AsyncCallback, Object)

When overridden in a derived class, begins an asynchronous operation to reply to the request associated with the current context.

System_CAPS_pubmethodBeginReply(Message, TimeSpan, AsyncCallback, Object)

When overridden in a derived class, begins an asynchronous operation to reply to the request associated with the current context within a specified interval of time.

System_CAPS_pubmethodClose()

When overridden in a derived class, closes the operation that is replying to the request context associated with the current context.

System_CAPS_pubmethodClose(TimeSpan)

When overridden in a derived class, closes the operation that is replying to the request context associated with the current context within a specified interval of time.

System_CAPS_protmethodDispose(Boolean)

Releases resources associated with the context.

System_CAPS_pubmethodEndReply(IAsyncResult)

When overridden in a derived class, completes an asynchronous operation to reply to a request message.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodReply(Message)

When overridden in a derived class, replies to a request message.

System_CAPS_pubmethodReply(Message, TimeSpan)

When overridden in a derived class, replies to a request message within a specified interval of time.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIDisposable.Dispose()

Releases both managed and unmanaged resources associated with the context.

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 null. 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 null. 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 null unexpectedly, check first whether the operation contract is IsOneWay.

Special note for Managed C++ 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 IDisposable.

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

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

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 3.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 3.0
Windows Phone Silverlight
Available since 7.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft