I have a controller named "AccountController" and action called "ResetPassword". From the html markup I can do something like:
<%= Html.ActionLink("LinkText", "ResetPassword", "AccountController") %>
and it will output the correct url. Is there a way to do this programmatically? I am trying to get the url as a string in another class but System.Web.Mvc.HtmlHelper doesn't have an ActionLink() static method and creating an instance of the class doesn't have it either.
Note: If I try to create instances of HtmlHelper or UrlHelper I then need references to the View Context or Request Context and I can't figure out how to get those from the controller (to pass in to my class method)
UrlHelper u = new UrlHelper(this. ControllerContext. RequestContext); string url = u. Action("About", "Home", null);
In MVC, routing is a process of mapping the browser request to the controller action and return response back. Each MVC application has default routing for the default HomeController. We can set custom routing for newly created controller.
RedirectToRoute(String, Object)Redirects to the specified route using the route name and route values.
A URL action is a hyperlink that points to a web page, file, or other web-based resource outside of Tableau. You can use URL actions to create an email or link to additional information about your data. To customize links based on your data, you can automatically enter field values as parameters in URLs.
Use Url.Action
instead.
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