I need to create an email from which the user is supposed to click on it to get to a ASP.NET MVC page.
The controller name is Truck and the action is Edit.
I am not sure how to put this into a hyperlink such that the user can go to a page.
Part of the issue is that in development, it says localhost… How can it be smart enough to get the path.
Apart from action and controller name you also need the hostname for this, as you said. You can get the hostname from
Requestobject inside the ASP.NET MVC controller.This is how I did this recently inside the controller to get the URL to a page, which I then included in emails. Works well for me both on localhost and hosting.
Urlis aUrlHelperthat is accessible inside ASP.NET MVC controller.Check out the MSDN documentation for the specific
UrlHelper.Action()method that I used. Seems that this is the only overload with the hostname parameter.