I have a class of service in an ASP.NET MVC 5 application that should generate the full route URL.
This class is called from the controller.
In the controller, I usually generate a route URL, for example:
string myUrl = Url.RouteUrl("ViewCust", new{custId=customerId},Request.Url.Scheme)
How can I create a route URL in a class that is not a controller?
I tried:
string myUrl = System.Web.Mvc.UrlHelper()
.RouteUrl(
routeName,
routeValues,
HttpContext.Current.Request.Url.Scheme);
The result is
'System.ArgumentNullException' The value cannot be null. Parameter Name: routeCollection
source
share