Alex Rivera | Logout

what is the difference between ViewData & PageData in asp.net MVC 3?

Asked 2011-06-21T16:58:08.120
14

Well i see this 2 properties but i cant understand the difference between them?
I cant seem to find any help anywhere about the PageData propriety.
so can any body help?

@
{
 Viewdata["something"] = 1;
 PageData["something"] = 2;
}

thanks

Edit
Report

1 Answer

2

I'm not 100% sure, but it looks like PageData is something from WebMatrix (MS's "light" web development environment). And ViewData is something that is fully supported in MVC. ViewData is in the System.Web.Mvc namespace, and therefore any MVC app will have it available.

PageData is apparently (according to MSDN) in the System.Web.WebPages namespace, but I can't access PageData from my MVC controllers, even if I fully qualify it. Maybe it's not meant to be accessed from the controller side, like ViewData can be...?

There's some more info on PageData in this other StackOverflow question here, but info on it around the web is surprisingly sparse (as you've probably found).

I hope that helps!

answered 2011-06-21T18:08:02.647

Your Answer