Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

endpoint.tv - How to Do API Key Verification with a WCF WebHttp (REST) Service

13 minutes, 23 seconds


Right click “Save as…”

In .NET 3.5, we created the REST Starter Kit as a way to get you up and running with RESTful services. Now that .NET 4 is out, people are asking how to do things like API Key Verification in .NET 4. In this episode, I'll walk you through a sample.

For more info


Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
  • Is there going to be a REST Starter Kit version for .NET 4??

  • Ron Jacobsrojacobs Ron Jacobs

    Still working on the plan.  Most of the server stuff ended up in .NET 4.  The only part that we don't have is the HttpClient library (which is really cool).  It totally works on .NET 4 if you just grab the source and build it.

  • How do we pass it in if we're using the WebReference ServiceClient object?

  • Sander van de VeldeSander van de Velde

    @Steve Scott: Thanks for your fine solution. I have changed it little so it can also be used with (OData) Service references. I also check the header of the request:
    public string GetAPIKey(OperationContext operationContext)
       var request = operationContext.RequestContext.RequestMessage;
       var requestProp =
       NameValueCollection queryParams =
      string apiKey = queryParams[APIKEY];
      if (apiKey == null)
        apiKey = requestProp.Headers[APIKEY];
      return apiKey;
    and on the client, i pass the ApiKey in the header using the SendingRequest event:
    service.SendingRequest += new 
    static void service_SendingRequest(object sender,
      System.Data.Services.Client.SendingRequestEventArgs e)
       e.Request.Headers.Add("APIkey", "918704ec-4811-45b6-a169-16bae3df69a8");
     See also:

Remove this comment

Remove this thread


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.