{"id":101,"date":"2014-05-09T09:45:00","date_gmt":"2014-05-09T08:45:00","guid":{"rendered":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/09\/viewdata-vs-viewbag-vs-tempdata\/"},"modified":"2014-05-09T09:45:00","modified_gmt":"2014-05-09T08:45:00","slug":"viewdata-vs-viewbag-vs-tempdata","status":"publish","type":"post","link":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/09\/viewdata-vs-viewbag-vs-tempdata\/","title":{"rendered":"ViewData VS ViewBag VS TempData ?"},"content":{"rendered":"<div class='booster-block booster-read-block'>\n                <div class=\"twp-read-time\">\n                \t<i class=\"booster-icon twp-clock\"><\/i> <span>Read Time:<\/span>1 Minute, 5 Second                <\/div>\n\n            <\/div><div dir=\"ltr\" style=\"text-align: left;\">\n<div style=\"background-color: white; color: #333333; margin: 0in 0in 0.0001pt; outline: none 0px;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif; outline: none 0px;\"><br \/><\/span><\/div>\n<table bgcolor=\"#ffffff\" border=\"1\" cellspacing=\"1\" style=\"border-collapse: collapse; color: #333333; outline: none 0px;\">\n<tbody style=\"outline: none 0px;\">\n<tr bgcolor=\"#e36c0a\" style=\"outline: none 0px;\">\n<td bgcolor=\"#0270bf\" height=\"33\" style=\"outline: none 0px;\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"color: white; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\"><b style=\"outline: none 0px;\">ViewData<\/b><\/span><\/div>\n<\/td>\n<td bgcolor=\"#0270bf\" height=\"33\" style=\"outline: none 0px;\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"color: white; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\"><b style=\"outline: none 0px;\">ViewBag<\/b><\/span><\/div>\n<\/td>\n<td bgcolor=\"#0270bf\" height=\"33\" style=\"outline: none 0px;\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"color: white; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\"><b style=\"outline: none 0px;\">TempData<\/b><\/span><\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 15pt; outline: none 0px;\">\n<td style=\"border-bottom-color: windowtext; border-left-color: windowtext; border-right-color: windowtext; border-style: none solid solid; border-width: medium 1pt 1pt; height: 15pt; outline: none 0px; padding: 0in 5.4pt; width: 176pt;\" valign=\"top\" width=\"235\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">It is Key-Value Dictionary collection<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 15pt; outline: none 0px; padding: 0in 5.4pt; width: 162.4pt;\" valign=\"top\" width=\"217\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">It is a type object<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 15pt; outline: none 0px; padding: 0in 5.4pt; width: 168.6pt;\" valign=\"top\" width=\"225\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">It is Key-Value Dictionary collection<\/span><\/span><\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 30pt; outline: none 0px;\">\n<td style=\"border-bottom-color: windowtext; border-left-color: windowtext; border-right-color: windowtext; border-style: none solid solid; border-width: medium 1pt 1pt; height: 30pt; outline: none 0px; padding: 0in 5.4pt; width: 176pt;\" valign=\"top\" width=\"235\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">ViewData is a dictionary object and it is property of ControllerBase class<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 30pt; outline: none 0px; padding: 0in 5.4pt; width: 162.4pt;\" valign=\"top\" width=\"217\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">ViewBag is Dynamic property of ControllerBase class.<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 30pt; outline: none 0px; padding: 0in 5.4pt; width: 168.6pt;\" valign=\"top\" width=\"225\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">TempData is a dictionary object and it is property of controllerBase class.<\/span><\/span><\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 15pt; outline: none 0px;\">\n<td style=\"border-bottom-color: windowtext; border-left-color: windowtext; border-right-color: windowtext; border-style: none solid solid; border-width: medium 1pt 1pt; height: 15pt; outline: none 0px; padding: 0in 5.4pt; width: 176pt;\" valign=\"top\" width=\"235\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">ViewData is Faster than ViewBag<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 15pt; outline: none 0px; padding: 0in 5.4pt; width: 162.4pt;\" valign=\"top\" width=\"217\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">ViewBag is slower than ViewData<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 15pt; outline: none 0px; padding: 0in 5.4pt; width: 168.6pt;\" valign=\"top\" width=\"225\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">NA<\/span><\/span><\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 30pt; outline: none 0px;\">\n<td style=\"border-bottom-color: windowtext; border-left-color: windowtext; border-right-color: windowtext; border-style: none solid solid; border-width: medium 1pt 1pt; height: 30pt; outline: none 0px; padding: 0in 5.4pt; width: 176pt;\" valign=\"top\" width=\"235\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">ViewData is introduced in MVC 1.0 and available in MVC 1.0 and above<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 30pt; outline: none 0px; padding: 0in 5.4pt; width: 162.4pt;\" valign=\"top\" width=\"217\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">ViewBag is introduced in MVC 3.0 and available in MVC 3.0 and above<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 30pt; outline: none 0px; padding: 0in 5.4pt; width: 168.6pt;\" valign=\"top\" width=\"225\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">TempData is also introduced in MVC1.0 and available in MVC 1.0 and above.<\/span><\/span><\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 30pt; outline: none 0px;\">\n<td style=\"border-bottom-color: windowtext; border-left-color: windowtext; border-right-color: windowtext; border-style: none solid solid; border-width: medium 1pt 1pt; height: 30pt; outline: none 0px; padding: 0in 5.4pt; width: 176pt;\" valign=\"top\" width=\"235\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">ViewData&nbsp; is also work with .net framework 3.5 and above<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 30pt; outline: none 0px; padding: 0in 5.4pt; width: 162.4pt;\" valign=\"top\" width=\"217\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">ViewBag&nbsp; is only&nbsp; work with .net framework 4.0 and above<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 30pt; outline: none 0px; padding: 0in 5.4pt; width: 168.6pt;\" valign=\"top\" width=\"225\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">TempData&nbsp; is also work with .net framework 3.5 and above<\/span><\/span><\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 45pt; outline: none 0px;\">\n<td style=\"border-bottom-color: windowtext; border-left-color: windowtext; border-right-color: windowtext; border-style: none solid solid; border-width: medium 1pt 1pt; height: 45pt; outline: none 0px; padding: 0in 5.4pt; width: 176pt;\" valign=\"top\" width=\"235\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">Type Conversion code is required while enumerating<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 45pt; outline: none 0px; padding: 0in 5.4pt; width: 162.4pt;\" valign=\"top\" width=\"217\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">In depth, ViewBag is used dynamic, so there is no need to type conversion while enumerating.<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 45pt; outline: none 0px; padding: 0in 5.4pt; width: 168.6pt;\" valign=\"top\" width=\"225\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">Type Conversion code is required while enumerating<\/span><\/span><\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 45pt; outline: none 0px;\">\n<td style=\"border-bottom-color: windowtext; border-left-color: windowtext; border-right-color: windowtext; border-style: none solid solid; border-width: medium 1pt 1pt; height: 45pt; outline: none 0px; padding: 0in 5.4pt; width: 176pt;\" valign=\"top\" width=\"235\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">It value become null if redirection is occurred.<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 45pt; outline: none 0px; padding: 0in 5.4pt; width: 162.4pt;\" valign=\"top\" width=\"217\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">Same as ViewData<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 45pt; outline: none 0px; padding: 0in 5.4pt; width: 168.6pt;\" valign=\"top\" width=\"225\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">TempData is used to pass data between two consecutive requests.<\/span><\/span><\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 28.75pt; outline: none 0px;\">\n<td style=\"border-bottom-color: windowtext; border-left-color: windowtext; border-right-color: windowtext; border-style: none solid solid; border-width: medium 1pt 1pt; height: 28.75pt; outline: none 0px; padding: 0in 5.4pt; width: 176pt;\" valign=\"top\" width=\"235\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">It lies only during the current request.<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 28.75pt; outline: none 0px; padding: 0in 5.4pt; width: 162.4pt;\" valign=\"top\" width=\"217\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"outline: none 0px;\"><span style=\"color: black; font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">Same as ViewData<\/span><\/span><\/div>\n<\/td>\n<td style=\"border-bottom-color: windowtext; border-right-color: windowtext; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 28.75pt; outline: none 0px; padding: 0in 5.4pt; width: 168.6pt;\" valign=\"top\" width=\"225\">\n<div style=\"margin-bottom: 0.0001pt; outline: none 0px;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif; outline: none 0px;\">TempData is only work during the current and subsequent request<\/span><\/div>\n<div>\n<span style=\"font-family: Arial, Helvetica, sans-serif; outline: none 0px;\"><br \/><\/span><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>ViewData ViewBag TempData It is Key-Value Dictionary collection It is a type object It is Key-Value Dictionary collection ViewData is a dictionary object and it is property of ControllerBase class ViewBag is Dynamic property of ControllerBase class. TempData is a dictionary object and it is property of controllerBase class. ViewData is Faster than ViewBag ViewBag [&hellip;]<\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[37],"tags":[],"class_list":["post-101","post","type-post","status-publish","format-standard","hentry","category-mvc"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Himanshu Namdeo","author_link":"https:\/\/debuggersspace.com\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"ViewData ViewBag TempData It is Key-Value Dictionary collection It is a type object It is Key-Value Dictionary collection ViewData is a dictionary object and it is property of ControllerBase class ViewBag is Dynamic property of ControllerBase class. TempData is a dictionary object and it is property of controllerBase class. ViewData is Faster than ViewBag ViewBag&hellip;","_links":{"self":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/101"}],"collection":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/comments?post=101"}],"version-history":[{"count":0,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/101\/revisions"}],"wp:attachment":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/media?parent=101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/categories?post=101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/tags?post=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}