Create/Generate an absolute url in webapi

To get the absolute Url to an action or route in your WebAPI controller that points to another action, play around with the following code:

If the route is set to null, the first mapped route in the global.asax file will be used. You can play around with the parameters and anonymous object to get the correct routing you need.

For absolute url in mvc, see