Eatdoku
Eatdoku

Reputation: 6971

asp.net web api generate url for a resource

i am trying to generate a url for a resource using asp.net web api. I can do that pretty easily in side ApiController, but what about I am not in the ApiController context?

Upvotes: 0

Views: 231

Answers (1)

Darrel Miller
Darrel Miller

Reputation: 142242

The long way is to get the request, dig out the Configuration and the RouteData from the properties collection, create yourself a ControllerContext and then you can use UrlHelper to general Urls.

There may be an easier way, but I haven't found it yet.

Upvotes: 1

Related Questions