After the action is executed, I need to access ViewData and TempData, is that possible?

Last post 02-24-2009 11:29 AM by jeloff. 1 replies.

Sort Posts:

  • After the action is executed, I need to access ViewData and TempData, is that possible?

    02-24-2009, 9:38 AM
    • Member
      98 point Member
    • random0xff
    • Member since 02-11-2007, 2:34 PM
    • Posts 208

    In the controller you need to be aware of the difference between ViewData and TempData in relation to redirects. I want to make it possible to put something in ViewData under a unique key and if the page is redirected move it to TempData right before the redirect.

    I was initially thinking about the Application.EndRequest event, but I don't know how to get to the ViewData or TempData from their. I can get the MvcHandler or RouteHandler, but neither seems to give me access to ViewData or TempData, or to the controller for that matter.

    How can I do this?

    Thanks!

    Filed under: , ,
  • Re: After the action is executed, I need to access ViewData and TempData, is that possible?

    02-24-2009, 11:29 AM
    Answer
    • Participant
      1,894 point Participant
    • jeloff
    • Member since 05-14-2008, 8:01 PM
    • Richmond, BC
    • Posts 368
    • AspNetTeam

    Hi

    Have you considered implementing an ActionFilter, specifically the OnResultExecuted?

    Jacques

Page 1 of 1 (2 items)