ASP.NET MVC 5 Hosting – How to Persist Data with TempData

In this article, I will explain to you how to persist data with TempData in ASP.NET MVC 5 using 2 methods. For your information, TempData is used to pass data from current request to subsequent request (means redirecting from one page to another). It’s life is very short and lies only till the target view is fully loaded. But you can persist data in TempData by calling Keep() method. ASP.NET 5 Hosting

3 Things that You should know about TempData and TempData.Keep()

1. Items in TempData will only tagged for deletion after they have read.
2. Items in TempData can be untagged by calling TempData.Keep(key).
3. RedirectResult and RedirectToRouteResult always calls TempData.Keep() to retain items in TempData.

TempData with Keep method

If you want to keep value in TempData object after request completion, you need to call Keep method with in the current action. There are two overloaded Keep methods to retains value after current request completion.

1. voidKeep() Method

Calling this method with in the current action ensures that all the items in TempData are not removed at the end of the current request.

 2. void Keep(string key) Method

Calling this method with in the current action ensures that specific item in TempData is not removed at the end of the current request. as The Best and Recommended ASP.NET MVC 5.0 Hosting Provider

Get high performance, best uptime and the most reliable for your ASP.NET MVC 5.0 Hosting. from provides a safe, reliable and performance-driven foundation for your website. If you are looking for the right ASP.NET MVC 5.0 hosting provider, they are the right choice for you. They have proactive monitoring down to seconds with reactive solutions in place to ensure the stability of the services they provide. All hosting servers are monitored 24/7/365. They use enterprise software to monitor their entire network infrastructure. Their best and recommended ASP.NET MVC 5.0 hosting price starts from Є3.00/month, It includes with Unlimited bandwidth, Unlimited disk space, and complete features. To that end, they have built an industry leading Windows and PHP web hosting platform featuring the best of modern technology and industry practices.

hostforlife banner

Leave a Reply

Your email address will not be published.