1

What is the best strategy to generate links or urls to other resources in a self-hosted WCF WebApi application, without hard-coding something like host or port, etc.

Is there something like a route-helper?

ckittel
  • 6,478
  • 3
  • 41
  • 71
Joachim Rosskopf
  • 1,259
  • 2
  • 13
  • 24

1 Answers1

1

Currently, AFAIK, there isn't specific support for link/url generation. However, you can access all the required information (e.g. scheme, host, port, uri template) via the description model. See https://pfelix.wordpress.com/2011/05/08/wcf-web-apidescription-model/

Pedro Felix
  • 1,056
  • 1
  • 8
  • 12
  • Thank you, more for your blog, than for this answer! Great resource of Information. I did now the following, passed the ServiceHost to the Resource-Implementation, registered all Resources in an IoC-Container. And now have an helper class, that asks all resources for mapping of links, etc. Much work. I think, that "linking" is currently a weak spot of the Web-Api. – Joachim Rosskopf Aug 11 '11 at 04:44
  • This post by José Romaniello is also relevant - http://joseoncode.com/2011/03/18/wcf-web-api-strongly-typed-resource-linker/ – Pedro Felix Aug 11 '11 at 21:12