title: Url.Link not working in WebAPI
body: <p>Using the unit test below .. Iam trying to test my webapi.</p>
  
  <pre><code>[Test]
  public void CheckControllerForCreate()
  {
      var config = new HttpConfiguration();
      config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
      var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/product");
      var route = config.Routes.MapHttpRoute("Foo", "api/{controller}/{id}");
      var routeData = new HttpRouteData(route, new HttpRouteValueDictionary { { "controller", "products" } });
      var controller = new ProductController
      {
          ControllerContext = new HttpControllerContext(config, routeData, request),
          Request = request,
          Url = new UrlHelper(request)
      };
  
      controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
  
      var result = controller.Create(new Product {Id = 4, Name = "Tomato Soup", Category = "Groceries", Price = 1});
  }
  
  [HttpPost]
  public HttpResponseMessage Create(Product product)
  {
      var url = Url;
      if (product == null)
          throw new HttpResponseException(new HttpResponseMessage{StatusCode = HttpStatusCode.BadRequest,ReasonPhrase = "Product is not specified"});
      products.Add(product);
      var response = Request.CreateResponse(HttpStatusCode.Created, product);
      string uri = Url.Link("Foo", product.Id);
      response.Headers.Location = new Uri(uri);
      return response;
  }
  </code></pre>
  
  <p>The Create Action throws an exception because <code>uri</code> is <code>null</code>. Now, the Url helper is correctly picking up the RouteName , otherwise there would be a RouteName not found exception. I am assuming that somethign is wrong with my configuration.</p>
  
  <p>I referred to <a href="http://www.peterprovost.org/blog/2012/06/16/unit-testing-asp-dot-net-web-api" rel="nofollow">http://www.peterprovost.org/blog/2012/06/16/unit-testing-asp-dot-net-web-api</a> and several other posts for unit testing the controllers.</p>
  
  <p>The WebAPI method is here on codeplex</p>
  
  <p><a href="http://aspnetwebstack.codeplex.com/SourceControl/changeset/view/1acb241299a8#src/System.Web.Http/Routing/UrlHelper.cs" rel="nofollow">http://aspnetwebstack.codeplex.com/SourceControl/changeset/view/1acb241299a8#src/System.Web.Http/Routing/UrlHelper.cs</a></p>
  
  <p>Edit </p>
  
  <p>I have narrowed it down to vpd being null in ( UrlHelper)</p>
  
  <pre><code>IHttpVirtualPathData vpd = configuration.Routes.GetVirtualPath(
                  request: request,
                  name: routeName,
                  values: routeValues);
  </code></pre>
  
  <p>Can't seem to figure out why ? </p>