1

In the controller, I'm setting TempData values in the controller like this:

TempData["LinkControllerName"] = "Foos";
TempData["LinkActionName"] = "View";

When I try to consume them in the View, I find they're always null. I can use the debugger and see them being set, and then see that in the View they're null. I'm mystified.

The controller action is in fact a child action, and the View is being rendered via a call to PartialView() in the parent controller. There's no redirection taking place. Can anyone suggest what the problem is?

1 Answer 1

3

This does not directly answer the question, but you hould use ViewData or ViewBag for passing extra values to the view from the Controller.

Sign up to request clarification or add additional context in comments.

1 Comment

Actually, you've sort of answered my question. I found that I was using TempData in the controller, and ViewData in the View. :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.