I have a controller ProgramSummary that I want to redirect to a second controller TRPResource. In the first controller for the detail view I have an actionLink:
@Html.ActionLink("Resource(s)", "TRPDetails", "TRPResource", new { ttl = ViewBag.shrt_titles })
It redirects to Requested URL: /ProgramSummary/TRPDetails which is the correct view but the wrong controller. If I change the actionLink to read (as follows)
@Html.ActionLink("Resource(s)", "TRPDetails", "TRPResource")
The actionlink works as I intend and goes to the correct controller and view but the problem being that the value is not maintained in the ViewBag and is not passed. What is the concept that I am missing here and/or can a work around or different approach be suggested?
You are using a wrong overload of the ActionLink helper. You should use the correct overload (notice the
nullat the end):whereas your code is using the following overload:
Notice the problem?