I need to create a route URL based on parameters as a part of a JSON return values.
What is the equivalent of Url.RouteUrl but to be used inside the controller code, So I can return a string in my Json result that contains the routeurl .
I need this done outside of the controller class, in a separate class, can this be done at all?
You can still use Url.RouteUrl
, but in a slightly different way.
Place a using System.Web.Mvc;
at the top of your class (of course, you might need to Add Reference to System.Web.Mvc).
Then get the Url object by:
UrlHelper Url = new UrlHelper(HttpContext.Current.Request.RequestContext);
and access as usual: Url.RouteUrl
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With