MVC Video :- Difference between viewdata,viewbag,tempdata and session.(MVC Interview questions)

Поділитися
Вставка
  • Опубліковано 18 січ 2013
  • Buy full MVC 5 & MVC CORE course from here www.questpond.com/learn-mvc-5...
    For more such videos visit www.questpond.com
    For more such videos subscribe ua-cam.com/users/questpondvide...
    See our other Step by Step video series below :-
    Learn C# Step by Step goo.gl/FNlqn3
    Learn Design Pattern Step by Step:- goo.gl/eJdn0m
    Learn Angular tutorial step by step tinyurl.com/ycd9j895
    Learn MVC Core step by step :- tinyurl.com/y9jt3wkv
    Learn Azure Step by Step :- tinyurl.com/y6fmrech
    Learn SharePoint Step by Step in 8 hours:- goo.gl/XQKHeP
    Python Tutorial for Beginners:- • Python Tutorial for Be...
    Learn Data Science in 1 hour :- tinyurl.com/y5o7qbau
    Learn Power BI Step by Step:- tinyurl.com/y6thhkxw
    Learn MSBI Step by Step in 32 hours:- goo.gl/TTpFZN
    Learn SQL Server Step by Step tinyurl.com/ja4zmwu
    Learn Tableau step by step :- tinyurl.com/kh6ojyo
    In this MVC ( Model view controller) video we will try to understand what is the difference between viewdata,viewbag,tempdata and session.This is an interesting MVC interview question and below is a textual answer for the same.
    Temp data: - Helps to maintain data when you move from one controller to other controller or from one action to other action. In other words when you redirect, "tempdata" helps to maintain data between those redirects. It internally uses session variables.
    View data: - Helps to maintain data when you move from controller to view.
    View Bag: - It's a dynamic wrapper around view data. When you use "Viewbag" type casting is not required.
    Want to Learn MVC 5 in 2 days start from the below video :-
    goo.gl/1br5mb
    The following syllabus has been covered in Learn MVC 5 in 2 days
    Learn MVC 5 in 2 days
    Lab 1 : - Simple Hello world(20 Minutes)
    Lab 2 : - Explain MVC Routing(10 Minutes)?
    Lab 3 : - Explain ViewData, ViewBag, TempData & Session Variables?(20 Minutes)
    Lab 4 :- Explain Model and Strongly typed views (20 minutes)?
    Lab 5 : - Explain Model Binders(10 minutes)?
    Lab 6 :- Why MVC and MVC vs Webforms ? (30 minutes)
    Lab 7 :- Explain TempData , Peek and Keep ? (10 Minutes)
    Lab 8 : - Explain Data Annotations and HTML Helpers classes?(31 Minutes)
    Lab 9 : - What is the need of ViewModel in MVC? (10 Minutes)
    Lab 10 : - How can we use Entity Framework in MVC?(20 minutes)
    Lab 11 : - How to implement viewmodel, partial view and webgrid?(45 minutes)
    Lab 12 : - What is the difference between ActionResult and ViewResult in MVC?(10 minutes)
    Lab 13 :- How to implement Ajax using Json and Jquery in MVC ? (60 Minutes)
    Lab 14 : - What is the use of Async Controllers in MVC?(20 minutes)
    Lab 15 :- How to deploy MVC Application on IIS ? (10 minutes)
    Lab 16 :- How can we do Windows and Forms Authentication in MVC? (50 Minutes)
    Lab 17 : - How can we use MVC areas for better modular development ? (10 Minutes)
    Lab 18 :- How to implement MVC with Angular ? (60 minutes) ?
    Lab 19 :- Can we Overload MVC Action methods ? (10 Minutes)
    Lab 20 :- How to improve Reusability using Angular ? (20 Minutes) ?
    Lab 21 :- What is the need of WebAPI in MVC ? (30 Minutes)
    Lab 22 : - How to do exception handling in MVC? (30 Minutes)
    Lab 23 :- How to do update and delete using MVC , WebAPI , EF and Angular? (30 Minutes)
    Lab 24 : - How to use MVC Webgrid?(30 minutes)
    Lab 25 :- How to implement Validation using Angular and MVC (30 minutes)?
    Lab 26 :- What is SPA (Single page application)?
    Lab 27 :- How to Organize MVC project and Understanding CORS issue ? (42 minutes)
    Lab 28 :- Explain the importance of DisplayModes ? (10 minutes)
    Lab 29 :- How to do unit testing with MVC projects (30 minutes)?
    Lab 30 :- How to implement SPA using Angular Routing ?
    Lab 31 :- How to create decoupled systems using MVC DI ?
    Lab 32 :- How can we have multiple submit buttons in ASP.NET MVC ?
    Lab 33 : - What is the importance of AntiForgery in MVC?
    Lab 34 :- What is the importance of ValidateInput and AllowHTML in MVC?
    Lab 35:- Bundling and Minification(15 minutes)
    Lab 36 :- Layout pages in Razor
    Lab 37: - What are ActionFilters in MVC?
    Lab 38: - What is WebAPI (Theory)?
    Lab 39: - How can we create and consume WEB API (Practical)?
    Lab 40 :- MVC 6/ASP.NET Core Training-Part 1 (2 Hours).
    Visit us at www.questpond.com for more details
    We are also distributing a 100 page Ebook "ASP.NET MVC". If you want this ebook please share this video in your facebook/twitter/linkedin account and email us on questpond@questpond.com with the shared link and we will email you the PDF.

КОМЕНТАРІ • 74

  • @dnfvideo
    @dnfvideo  2 роки тому +1

    Do not miss our Interview Question video series
    25 Important ASP.NET Interview Questions : ua-cam.com/video/pXmMdmJUC0g/v-deo.html
    30 Important C# Interview Questions : ua-cam.com/video/BKynEBPqiIM/v-deo.html
    25 Angular Interview Questions : ua-cam.com/video/-jeoyDJDsSM/v-deo.html
    5 MSBI Interview Questions : ua-cam.com/video/5E815aXAwYQ/v-deo.html

  • @praveendubey1994
    @praveendubey1994 9 років тому +2

    Thanks , Awesome, Short, Simple and helps to understand exactly what is needed.

  • @dpkbahuguna
    @dpkbahuguna 11 років тому +3

    The session is very descriptive and informative to set the basics of MVC.
    Thanks...Keep posting the Training :-)

  • @bjblk1
    @bjblk1 8 років тому +1

    Excellent video. Thank you very much. I will eventually watch all of your videos.

  • @monsieurrodriguez9687
    @monsieurrodriguez9687 11 місяців тому +2

    you didn't test the same name in the viewbag controllers communication example, at minute eleven, you put ViewBag.CurrentDateTime while actually it was named ViewBag.CurrentDateANDTime.
    Anyway, thanks for the video, the point was explained successfully

  • @amishkumar5320
    @amishkumar5320 10 років тому +2

    enjoyed alot with your videos keep good works on thanks

  • @wase39
    @wase39 10 років тому +2

    very simple and elegant lesson

  • @mohamedsaied5780
    @mohamedsaied5780 6 років тому

    Good video and good explanation regardless the small mistakes.

  • @RaviHandsome
    @RaviHandsome 10 років тому +14

    Example is incorrect though concept is right.
    CurrentDateAndTime and CurrentDateTime are different at 12:20

  • @manishkjanu
    @manishkjanu 11 років тому

    Very useful information. Thanks!

  • @JayadevNelli
    @JayadevNelli 7 років тому

    Very good video, thank you for posting.

  • @MrSanjdhi
    @MrSanjdhi 11 років тому

    nice efforts for beginners and all. Keep it up.

  • @coolayer
    @coolayer 11 років тому

    Thanks Brother! It was very helpful.

  • @CodeSbyAniz
    @CodeSbyAniz 3 роки тому

    Great Job. Thanks for the video

  • @dnfvideo
    @dnfvideo  11 років тому

    Sorry it was my mistake to type the wrong property name.

  • @TubaMirza-co7ql
    @TubaMirza-co7ql Місяць тому

    11 years old video waw .. still knowledgeable

  • @218manish
    @218manish 10 років тому

    Nice & useful Tutorial

  • @theUnboxerfalcon
    @theUnboxerfalcon 6 місяців тому

    Thank you for a brilliant video..

  • @TheAsimiy
    @TheAsimiy 10 років тому

    Very nice tutorial .... thanks Sir

  • @ims4666
    @ims4666 3 роки тому

    Awesome explanation....

  • @fcinternetmarketing
    @fcinternetmarketing 10 років тому

    Love this video.

  • @bhuvanatn
    @bhuvanatn 11 років тому

    Thanks very much..very helpful

  • @Robsonsantosxd
    @Robsonsantosxd 9 років тому

    Could anyone send the link of the next lesson ? i couldn't find it.
    Great Lesson BTW!

  • @talalshoaib3099
    @talalshoaib3099 8 років тому

    Very nice video thank you sir :)

  • @manoharjulakanti8688
    @manoharjulakanti8688 7 років тому

    hi sir, i used temp data in view and also in action method ...then also data is transferring from action method to view.....

  • @rohanthakur6136
    @rohanthakur6136 6 років тому

    Excellent video sir. Thank you very much. how to get MVC Asp.Net Q & A Series.

  • @tsogiaidze
    @tsogiaidze 9 років тому

    Great!

  • @VannaraLoch
    @VannaraLoch 10 років тому +11

    but your two viewBag variable is not the same...one is CurrentDateAndTime one is CurrentDateTime

  • @rohitashkumar7765
    @rohitashkumar7765 8 років тому

    Nice video

  • @rprabhuit
    @rprabhuit 10 років тому +18

    wrong statement on TempData usage. TempData can be used from controller to view as well. The TempData will be reset to null, only after it was read or used. But we can keep the data's in TempData after read by calling TempData.Keep() function. The Keep() should be called immediately after TempData object used.

    • @prateekbhardwaj9943
      @prateekbhardwaj9943 8 років тому +1

      +Prabhu Raja Exactly i was thinking the same.. but every where i read this that tempdata for controller to controller ... ? is it true for mvc 3? or in mvc 4 we can use controller to view (one cycle)

    • @nimitjoshi8639
      @nimitjoshi8639 8 років тому +4

      I have worked on MVC 5 project and in that i have used TempData to pass the info from Controller to View.

    • @mohamedsaied5780
      @mohamedsaied5780 6 років тому +1

      msdn.microsoft.com/en-us/library/system.web.mvc.tempdatadictionary(v=vs.118).aspx
      You can use a TempDataDictionary object to pass data in the same way that you use a ViewDataDictionary object. However, the data in a TempDataDictionary object persists only from one request to the next, unless you mark one or more keys for retention by using the Keep method. If a key is marked for retention, the key is retained for the next request.
      A typical use for a TempDataDictionary object is to pass data from an action method when it redirects to another action method. For example, an action method might store information about an error in the controller's TempData property (which returns a TempDataDictionary object) before it calls the RedirectToAction method. The next action method can then handle the error and render a view that displays an error message.

  • @rohitshinde8145
    @rohitshinde8145 4 роки тому

    helpful ty.

  • @dnfvideo
    @dnfvideo  9 років тому

    Want to Learn MVC 5 in 2 days start from the below video :-
    goo.gl/1br5mb
    The following syllabus has been covered in Learn MVC 5 in 2 days
    Learn MVC 5 in 2 days
    Lab 1 : - Simple Hello world(20 Minutes)
    Lab 2 : - Explain MVC Routing(10 Minutes)?
    Lab 3 : - Explain ViewData, ViewBag, TempData & Session Variables?(20 Minutes)
    Lab 4 :- Explain Model and Strongly typed views (20 minutes)?
    Lab 5 : - Explain Model Binders(10 minutes)?
    Lab 6 :- Why MVC and MVC vs Webforms ? (30 minutes)
    Lab 7 :- Explain TempData , Peek and Keep ? (10 Minutes)
    Lab 8 : - Explain Data Annotations and HTML Helpers classes?(31 Minutes)
    Lab 9 : - What is the need of ViewModel in MVC? (10 Minutes)
    Lab 10 : - How can we use Entity Framework in MVC?(20 minutes)
    Lab 11 : - How to implement viewmodel, partial view and webgrid?(45 minutes)
    Lab 12 : - What is the difference between ActionResult and ViewResult in MVC?(10 minutes)
    Lab 13 :- How to implement Ajax using Json and Jquery in MVC ? (60 Minutes)
    Lab 14 : - What is the use of Async Controllers in MVC?(20 minutes)
    Lab 15 :- How to deploy MVC Application on IIS ? (10 minutes)
    Lab 16 :- How can we do Windows and Forms Authentication in MVC? (50 Minutes)
    Lab 17 : - How can we use MVC areas for better modular development ? (10 Minutes)
    Lab 18 :- How to implement MVC with Angular ? (60 minutes) ?
    Lab 19 :- Can we Overload MVC Action methods ? (10 Minutes)
    Lab 20 :- How to improve Reusability using Angular ? (20 Minutes) ?
    Lab 21 :- What is the need of WebAPI in MVC ? (30 Minutes)
    Lab 22 : - How to do exception handling in MVC? (30 Minutes)
    Lab 23 :- How to do update and delete using MVC , WebAPI , EF and Angular? (30 Minutes)
    Lab 24 : - How to use MVC Webgrid?(30 minutes)
    Lab 25 :- How to implement Validation using Angular and MVC (30 minutes)?
    Lab 26 :- What is SPA (Single page application)?
    Lab 27 :- How to Organize MVC project and Understanding CORS issue ? (42 minutes)
    Lab 28 :- Explain the importance of DisplayModes ? (10 minutes)
    Lab 29 :- How to do unit testing with MVC projects (30 minutes)?
    Lab 30 :- How to implement SPA using Angular Routing ?
    Lab 31 :- How to create decoupled systems using MVC DI ?
    Lab 32 :- How can we have multiple submit buttons in ASP.NET MVC ?
    Lab 33 : - What is the importance of AntiForgery in MVC?
    Lab 34 :- What is the importance of ValidateInput and AllowHTML in MVC?
    Visit us at www.questpond.com for more details

    • @naeemahmad9698
      @naeemahmad9698 9 років тому

      .NET Interview Preparation videos sir from where i can get complete video series please guide

    • @dnfvideo
      @dnfvideo  8 років тому

      +Naeem Ahmad Please visit www.questpond.com and mail to us on questpond@questpond.com

  • @ARV-sf5td
    @ARV-sf5td 5 років тому +1

    What is the difference between tempdata keep and peek

  • @arunvenkatesh6464
    @arunvenkatesh6464 5 років тому

    PLS MAKE VIDEO ON CASCADING DROP DOWN LIST
    LOAD DATA FROM DATABASE AND SAVE DATA TO DATATBASE

  • @chandanadas7860
    @chandanadas7860 4 роки тому +1

    tempdata is controller to controller and also controller to view

  • @SultanAhmed-xx1oz
    @SultanAhmed-xx1oz 2 роки тому

    THank YUo

  • @92_shwetadhande92
    @92_shwetadhande92 11 місяців тому

    sir please provide link of how to pass data from view to controller?

  • @bhaktilife111
    @bhaktilife111 Рік тому

    So beautiful

  • @knowledgeys6652
    @knowledgeys6652 5 років тому

    I believe Tempdata sends the data from one view to other View..

  • @odytrice
    @odytrice 10 років тому

    You can also pass TempData to the View

  • @akashverma1640
    @akashverma1640 2 роки тому

    Sir at 12:07 you have used wrong name of variable in viewbag i.e viewbag.CurrentDateTime instead of Viewbag.CurrentDateAndTime that is why it's null.

  • @amruthbinish
    @amruthbinish 11 років тому

    how can we create mvc views faster and make them strong typed by using html helper ---where this video?

  • @balaram438
    @balaram438 9 років тому

    thanks you so much it was nice explanation

  • @akshaygaikwad817
    @akshaygaikwad817 9 років тому +15

    you have given wrong viewbag name in sampleview1 while geting its data in string varible and shown null value

    • @shailabgupta8746
      @shailabgupta8746 8 років тому

      +akshay gaikwad, yes i also caught this problem

    • @nimitjoshi8639
      @nimitjoshi8639 8 років тому

      Yes. I was thinking about to mention it. But i saw your comment which is related to this. +1

    • @Nandakishore48
      @Nandakishore48 7 років тому

      yaa dude you are right

    • @mohamedsaied5780
      @mohamedsaied5780 6 років тому

      yes, CurrentDateAndTime while in another CurrentDateTime but it will lead to null also if he typed it correct as viewbag cann't transfer data between controllers

  • @niteshkr.upadhyay3506
    @niteshkr.upadhyay3506 2 роки тому

    Is it really wrong?
    At 11:17 he added a value in ViewBag.CurrentDateAndTime but was receiving with ViewBag.CurrentDateTime
    That's wrong na?
    How will it fetch the value?

  • @prateekbhardwaj9943
    @prateekbhardwaj9943 6 років тому

    you should correct the information, this is a very old video. controller to view is possible in tempdata aslo

  • @ragavaragala9116
    @ragavaragala9116 4 роки тому

    In action method samlpeview you mentioned current dateandtime but second action method you mentioned current datetime you don't mentioned and

  • @sinchanar440
    @sinchanar440 5 років тому

    Sir, I have a question please give me a reply. How do I set session for multiple user login and I want to differentiate as Admin and local user...

    • @RanjeetKumar-gg7ie
      @RanjeetKumar-gg7ie 4 роки тому

      through authorization differentiate between admin & local user , also set HttpContext.Current.Session.Timeout = x ,( x is time ) to set diff timeout as per user accessibility..

    • @RanjeetKumar-gg7ie
      @RanjeetKumar-gg7ie 4 роки тому

      Create a master base class inherit it on master page
      if you are storing information in session about user type
      and write a function
      if(Session["admin"] !=null){
      if(Session["admin"].ToString() == "True")
      {
      HttpContext.Current.Session.Timeout = 120;
      }if(Session["user"].ToString() == "True")
      {HttpContext.Current.Session.Timeout = 60;
      }else
      {HttpContext.Current.Session.Timeout = 30;}
      }
      or you can replace session with profile if you are using profile

  • @multanimohsin8800
    @multanimohsin8800 9 років тому

    where is the lab 9

  • @sujanvaland
    @sujanvaland 10 років тому

    its not that we tempdata is not maintain from Controller to View, we can maintain the data

  • @NeelanjanaDutta
    @NeelanjanaDutta 7 років тому

    I cannot see any view engine drop down list in the add view page. so I cannot open aspx view. kindly suggest.

    • @dnfvideo
      @dnfvideo  7 років тому

      Please mail us your query at questpond@questpond.com

    • @sameerkhatri1918
      @sameerkhatri1918 6 років тому

      If you get the solution please let me know or you can send me an email on ersameer.khan05@gmail.com

  • @mayanksingh3277
    @mayanksingh3277 7 років тому

    hi

  • @prashantkumar15689
    @prashantkumar15689 4 роки тому

    In case of view bag you set another variable and tried to get value from wrong variable. Don't try to confuse viewers and don't anything wrong. Concept is right what you said but demonstrated wrongly.

  • @donfeto7636
    @donfeto7636 5 років тому

    information are not complete you give so little info

  • @s3123ww
    @s3123ww Рік тому

    @questpond : Now, We can pass data from controller to view using Tempdata. Please remove your old videoz, i beg. Outdated information can be harmful to your brand.

  • @bjblk1
    @bjblk1 8 років тому +1

    Excellent video. Thank you very much. I will eventually watch all of your videos.

  • @bjblk1
    @bjblk1 8 років тому

    Excellent video. Thank you very much. I will eventually watch all of your videos.