locked
Getting custom parameters in URL RRS feed

  • Question

  • Hello,

    I'm developing WCF Data Service with a custom data provider.

    My question is about custom parameters in URL.

    Suppose that an user make a request with the url: http://localhost/OData/OData.svc/Customer?Language=en

    In this context, Customer is an entity and Language is a parameter.

    How can I get the parameters?

    Friday, April 26, 2013 3:54 PM

Answers

  • In your DataService<T> implementation you can do something like this...

    // Note: OnStartProcessingRequest will get called for each part in a $batch request.
    protected override void OnStartProcessingRequest(ProcessRequestArgs args)
    {
        string customHeaderValue = args.OperationContext.GetQueryStringValue("customHeader");
    }
    

    Regards

    Uffe

    Saturday, April 27, 2013 4:16 AM

All replies

  • I think that I can use this way: http://www.codeproject.com/Articles/393623/OData-Services#ServiceOperations

    Friday, April 26, 2013 4:16 PM
  • In your DataService<T> implementation you can do something like this...

    // Note: OnStartProcessingRequest will get called for each part in a $batch request.
    protected override void OnStartProcessingRequest(ProcessRequestArgs args)
    {
        string customHeaderValue = args.OperationContext.GetQueryStringValue("customHeader");
    }
    

    Regards

    Uffe

    Saturday, April 27, 2013 4:16 AM
  • Service operations and custom query options are both 'correct' here.

    If you are thinking of these parameters as parameters specific to a GET request on an EntitySet, then I think Service Operations makes more sense.

    If you are thinking of these parameters as general extra info that might be valid on many request types, then custom query options makes more sense, and I'd follow Uffe's example. I believe that Language=en would fall into this category.


    -Ian

    Monday, April 29, 2013 3:50 PM