QueryStringConverter Class
This class converts a parameter in a query string to an object of the appropriate type. It can also convert a parameter from an object to its query string representation.
System.ServiceModel.Dispatcher::QueryStringConverter
System.ServiceModel.Dispatcher::JsonQueryStringConverter
Assembly: System.ServiceModel.Web (in System.ServiceModel.Web.dll)
The QueryStringConverter type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | CanConvert | Determines whether the specified type can be converted to and from a string representation. |
![]() | ConvertStringToValue | Converts a query string parameter to the specified type. |
![]() | ConvertValueToString | Converts a parameter to a query string representation. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
Parameters can be specified in a query string within a URL. This class takes those parameters specified in a string and converts them into objects. For example, the following contract is defined.
[ServiceContract]
interface Calculator
{
[WebGet(UriTemplate="Add?n1={n1}&n2={n2}")]
[OperationContract]
long Add(long n1, long n2);
}
A service implements this interface and exposes it on an endpoint with the WebHttpBehavior at http://localhost:8000/MyCalcService. The Add service operation can be called by sending an HTTP GET to http://localhost:8000/MyCalcService/Add?n1=10&n2=5. The QueryStringConverter receives this URL and converts the two parameters (n1 and n2) specified in the URL into two long objects with the appropriate values.
You can derive a class from QueryStringConverter to control how query string parameters are mapped into a service operation's parameters.
The QueryStringConverter supports the following types by default:
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
