Does anyone know why Setting TempData slows down my site completely?

Jason Huynh 1 Reputation point
2022-07-08T03:36:07.21+00:00

Hi All, using EF6 with C# and I tried to store a text value in TempData["name] , and then redirect to another view page to retrieve the data but whenever I set something for TempData my entire site slows down to a crawl. Whenever I don't use TempData my site works quick! Its really odd, would anyone know what might cause this?

Thanks!

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,251 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Yijing Sun-MSFT 7,066 Reputation points
    2022-07-08T07:27:34.103+00:00

    Hi @JasonHuynh-5315 ,
    First, you must know the characteristic of the TempData.

    1. TempData is derived from TempDataDictionary class
    2. TempData is used to pass data from the current request to the next request
    3. It keeps the information for the time of an HTTP Request. This means only from one page to another. It helps to maintain the data when we move from one controller to another controller or from one action to another action
    4. It requires typecasting for complex data type and checks for null values to avoid error.

    It needs to go through a series of operations. So, it will make your site slowly.

    Best regards,
    Yijing Sun


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Bruce (SqlWork.com) 55,601 Reputation points
    2022-07-08T15:50:30.743+00:00

    as tempdata is stored in a cookie, and passed with every request its size effects performance. use the browser tools to see how large it is.


  3. Bruce (SqlWork.com) 55,601 Reputation points
    2022-07-11T22:36:54.087+00:00

    which tempdata uses session state. which session state provider did you use? (I assumed you used the simple cookie based one).