TempData and Cookies in ASP NET Core MVC | Day 15 | Pranaya Rout | Dot Net Tutorials

Опубликовано: 30 Октябрь 2024
на канале: Dot Net Tutorials
318
5

TempData and Cookies in ASP NET Core MVC | Day 15 | Pranaya Rout | Dot Net Tutorials | Online Training

At the end of this video, you will understand the following pointers.

TempData in ASP.NET Core MVC
Why do we need TempData in the ASP.NET Core MVC Application?
What exactly is TempData in ASP.NET Core MVC?
How to use TempData?
How to Pass and Retrieve Data from TempData?
How to Retain TempData values in the Consecutive Request in ASP.NET Core MVC?

Cookies in ASP.NET Core MVC
What is a Cookie?
Types of Cookies
How do you Write, Read, and Delete Cookies in ASP.NET Core MVC?
Advantages and Disadvantages of using Cookies in ASP.NET Core MVC
When to use Cookies in ASP.NET Core MVC?

Why do we need TempData in the ASP.NET Core MVC Application?
As we already discussed in our previous articles, we can use ViewData, ViewBag, and Strongly Typed Models to pass the data from a controller action method to a view. Now, we will see another approach to send the data from the controller action method to a view in the ASP.NET Core MVC Application using the TempData.

The limitation of both ViewData and ViewBag is they are limited to one HTTP request only. So, if redirection occurs, their values become null, meaning they will lose the data they hold. In many real-time applications, we may need to pass the data from one HTTP Request to the next subsequent HTTP Request. For example, we may need to pass the data from one controller to another or one action method to another within the same controller. Then, in such situations like this, we need to use TempData in ASP.NET Core MVC Application.

What is TempData in ASP.NET Core MVC?
In ASP.NET Core MVC, TempData is a feature that allows us to store temporary data that will be available for the next request. It’s a mechanism to pass data between different actions or controllers during the lifetime of a user’s session. TempData is typically used when you need to show a message or provide some information to the user after a redirect.

TempData is implemented using the session state. It stores data in the session between requests, but unlike regular session data, TempData is meant to be short-lived and is removed automatically once it’s read or after the subsequent request is processed.

What is a Cookie?
A cookie is a small text file that a website stores on a user’s computer or mobile device when they visit the site. This file contains information that can be used to identify the user, such as their login status or preferences, and is sent back to the website with every subsequent request. Typically, it tells the web server if two requests are coming from the same web browser.

Text Document Links:
TempData in ASP.NET Core MVC: https://dotnettutorials.net/lesson/te...
Cookies in ASP.NET Core MVC: https://dotnettutorials.net/lesson/co...

You can contact us for live training using the Mobile Number, WhatsApp Number, and Email ID below.
Contact Number: 91 7021801173
WhatsApp Number: 91 7021801173
Email ID: [email protected]
Telegram Group: https://telegram.me/dotnettutorials

#TempDataInMVC #CookiesInMVC #TempDataCookiesMVC #ASPDOTNETCoreMVC #ASPDOTNETCore #DotNet #CSharp #DotNetCore #EntityFramework #EntityFrameworkCore #MSSQLServer #LINQ #dotnetcoreinterview #ADO #SOLID #DesignPattern #DotNetTraining #MVC #WebAPI #JOB #Interview #dotnetjob #dotnetinterview #dotnettutorials #pranaya #Developers