ASP.NET MVC: reassign TempData?

I think you're looking for TempData.Keep().

TempData only persists within the context of the current request. If you are returning content to the client, and then the client is posting back, you can't use that. Your options are pretty standard, and basically only as you described: Use a form variable (as you stated - and I'm guessing if it's a change password field then it may be sensitive) Use a session variable (as you stated also!) Persist the variable elsewhere in your application - custom database field or user profile or similar Personally I'd go with a session provider, or try to avoid returning content to the client with the immediate post back altogether, if possible...

If myVariable is not a critical information security you can persit it to dden field (change the view) and post it to next action request.

As I need to persist that datum for another call, I try to reassign it before returning the view. I immediately submit a POST request from the rendered page back to ChangePassword, but this time TempData"myVariable" is null. Maybe I'm doing something stupid, but how to get the wanted result?

I don't want to use a Session variable (it would persist much longer and I'd be working on ensuring manually that the variable is cleared to prevent the pollution of Session variables).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions