0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

yeah it'll be nice if the UrlHelper can be injected without manually construct the context~

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.