The detail view – posts on specific threads
Now that we have a list of threads, it's time to enable us to view a single thread and its posts. We want to click an item in the thread list and then be taken to a view that shows the content in the form of posts for this thread.
Navigating to a thread to see the posts
With a functional thread list, we now want to create the view to click a thread in the list. Let's start by adding another controller action that will take us to the view. Open the ForumController.cs
file in the Controllers
folder. Add the following method at the bottom of the class:
public ActionResult Thread(int id) { return View(); }
The Thread
action needs a Thread
view. Add, as before, a view by right-clicking on the Forum
folder sitting in the Views
folder of the project and select View from Add. Name it Thread
, leave the defaults, and then click on Add.
Adding the view content for a thread
The new Thread
view will be similar to what we had for the Index
view,...