I needed to have a class external to the controller’s and views that could generate a correctly formed Url using the UrlHelper.
I found this question on Stackoverflow which helped me with a solution. The solution was as follows:
HttpContextWrapper httpContextWrapper =
UrlHelper urlHelper = new UrlHelper(
I previously got confused about the RouteData object, but it seems (unless I’m mistaken) to essentially be route values, which in this case i don’t need… Not sure on that though!
As constructed above, the UrlHelper is able to take the RequestContext and get all the registered routes and therefore generate a correctly structured url when you call Action etc.