MVC 2.0 TempData Expiration?
Jul 3, 2010What happens in Asp.Net MVC 2.0, when next request does not come ever to retrieve value from TempData. Is it stored permanently or expires?
View 1 RepliesWhat happens in Asp.Net MVC 2.0, when next request does not come ever to retrieve value from TempData. Is it stored permanently or expires?
View 1 Repliestempdata variables works like a session variables?
basically i want to do is to when the form loads for the first time the variables should be empty. but the variable should be persisted until i am on that form.
the form contains searching with a submit button as well as the paging . basically my ques is to use what approach should i use?
i am using TempData to store the referrer for a website and via jquery i am issueing ajax calls to send emails ... I use tempdata to recover the original referrer URL.
It works great on the first read but then the second its empty.... I think this is by design... so i decided to try viewdata but this is stored but when read via the controller on an ajax call it is empty..
Does anyone know what my options are?
Here is the syntax of both lines
TempData["referrer"] = referrer; // WORKS great on first read and then is NULL
ViewData["referrer"] = referrer; // IS STORED but on first read is NULL
I have a method, which fill TempData:
[Code]....
so, I redirected to referrerUrl ([URL] then I even go to page: [URl] (Ideas method does not have any actions with TempData) and then go to [URL]
[Code]....
and it goes to selected by "GO TO HERE!!!" with value [URL]
So TempData works on my local machine in chrome, but not out on the server. It works fine in IE and firefox. I'm using the default Session State as InProc. I can see the cookie in chrome by looking at the developer tools.
View 4 RepliesI am working with ASP.net MVC 2 framework, for multiple sites. We have a base site and then sub sites that inherit from a "Core" site that contains 90% of the functionality that the sub sites will use.
In one of the controllers, I am saving some data, adding a UI message to the tempData and then using Response.Redirect.
The redirect works, but the tempdata is empty after the redirect.
I have tried returning "RedirectToAction" and "RedirectToRoute" with the same routing location and while it populates the TempData, the redirect doesn't happen lol..
So I guess in short, is there a way to get tempdata working when using a standard Response.Redirect?
I was under the impression that TempData was only persisted across one action but I am seem to be seeing the behaviour that it is persisted across one action only on the same controller.For example in a single controller if I do the following in my Event Controller,
TempData("test") = "Moo"
And then after displaying a view I then move to a new action (either by a GET or POST or redirect) I can read back the data,
TempData("test") = "Moo"
If I then move on to another action (either by a GET or POST or redirect) and check for TempData("test") I should get Nothing.However I have just tried this with two controllers and I get a very bizarre problem.For example on my first Controller, called Event Controller I set the TempData("test") = "Moo".I then move to an action on a second controller called Main Controller. I read back TempData("test") and find "Moo" as the result which is to be expected. I then perform some sort of task and a new GET, POST or Redirect request is made back to the Event Controller.
At this point I am expecting TempData("test") to be nothing, since I have already passed it to an action once already. However when I test this I am actually getting TempData("test") = "Moo" which I thought was not the expected behaviour, since in effect it would be like using Session("test) instead.
Some of my controller actions look for data in TempData. How can I insert data into TempData from my unit tests?
View 1 RepliesWe used MVC TempData to store smallish view state prior to redirects. This works worked great on our single Win2008 development server. Unforunately, the use of TempData no longer works in our load balanced production server farm. What steps are required to make MVC TempData durable across web servers?
View 4 RepliesThe WebFarm we are using doesn't supports Session. We are in a requirement to pass Data during redirects. How to do this without TempData dictionary since TempData uses Session inside.
View 2 RepliesI'm learning about storing state in 'TempData' when performing the PRG (Post-Redirect-Get) pattern. It says TempData stores session state on the server. I'm wondering if this is safe or unsafe in a load-balanced server farm?
Are there precautions to be taken with TempData? Or can we happily program against it with abandon. Just wanting to avoid the frights we all got with the Session back in the day with ASP.NET of old.
Working through Steven Sanderson's excellent Pro ASP.Net MVC Framework book.I am trying to reference the TempData collection to display a message after an item has been successfully updated and so have placed a reference to this on my Master Page.[Code]....
This is giving me the following compile time errors:
Error 1 The name 'TempData' does not exist in the current context <programme location>
Error 2 The name 'TempData' does not exist in the current context <programme location>
If I reference TempData on a content page it compiles (and works) fine.
I'm creating image (jpg) at run time in my application (ASP.NET/C# 3.0). I need to delete the created image after 30 mins. So is it possible to set expiration to the image after 30 mins when creating the image like setting expiration to cookies.
View 3 RepliesI'm programatically sending an email and I want to set it to expire after a certain amount of time. I tried using the following but it doesn't seem to work:
message.Headers.Add("Expires", Now.AddMinutes(2))
I can see the value in the header but the email doesn't actually expire.
I am not sure if I am asking this question correctly. Sometimes when you don't know enough, you may not know what to ask. I want to set up memberships with an ASP.NET website. The memberships will have a 14 day free trial period. After that, the user will need to pay a fee if they wish to continue to access the website. I am not sure how to accomplish this. After adding a membership database to the website, setting up roles ect., what do I do next? Do I need to make adjustments to the tables of the database, or write some code somewhere in the application? I have never done this exercise before, Logically, I know that I need to implement something that keeps track of expiration date. Also, how do I prevent a user from just making up new user names and credentialing?
View 4 RepliesI am creating some cookies in my ASP.NET application. These cookies expire 10 minutes after they have been created. I follow the approach described on MSDN as shown here:[URL]
My question is, when a cookie "expires", what happens? Does the browser automatically delete the cookie? Is it our responsibility as developers to remove the cookies if they exist and have expired?
1) How/where do I set the lifetime of the session cookie in my web application when using an STS to get claims? From what I can tell, it seems I can only do this programmatically in the erviceConfigurationCreated event.
2) How/where can I make sure that the expiration is sliding?
How to realize auction expiration? Make it inactive after 1-3-5 days? Something like eBay?I am using asp.net c#.I have "active" boolean field in my auction table.
View 1 RepliesI've been doing web development for a while and have yet to read a good answer to this question: iven a page that executes transactions through a postback, how do you prevent the user from duplicating the transaction when they do something as simple as hit the back button? I've explored trying expire the cache but I must admit I'm lacking in my understanding of ASP.NET caching. What is the approach I should use to make the old request stale and invalid?
View 2 RepliesI have asp.net application. I'm using external javascript files in my application. When I test my site with page speed tool from google it says that following resources are missing a cache expiration. also some of the images and css files.
View 2 RepliesI am in need for setting content expiration to immediate for certain parts of my website. Basically we want to expire the "shopping" pages but the browsing pages shouldn't expire allowing users the ease of using the back button to browse around. Is there a way to enable it per page, master page, folder, or something?
View 1 RepliesWhat may be the disadvantages of enable content expiration in IIS 6 ?
View 1 Repliesam a ASP.NET developer using Facebook Developer Toolkit to develop a facebook flash application with flash developer.When the user plays the game for a certain period of time, there are chances that the facebook session expires and I can't call any Facebook API for processing as a result.
View 2 RepliesIn an ASP.NET MVC2 app, we have the standard login action...
if (ValidateUser(model.Email, model.Password)
{
FormsAuthentication.SetAuthCookie(model.Email, model.RememberMe);
[code]...
I don't know if the following is possible or not but in brief, here is what I'm trying to achieve:
1. When a user requests to view a document, they click on a link (could be other) which contains an encrypted query string containing data required to retrieve the relevant document. i.e.[URL]
2. I want to ensure that if after x minutes the user goes back to their history and select the link again or re-type the same url as above that it will not request the document and redirect them to a page letting them know that the requested document "link" is no longer valid.
I don't want to rely on cookies or sessions, so thought that maybe there would be a way to add a datetime token at the end of the existing url but this needs to be done at run-time as the url is already predefined when the link is created, so I'm not sure how can I do this?
ideally, I'd like something like this [URL] where the token would contain the date & time when the link was clicked.
Once re-requested, I would decrypt the token and validate it again the server time and if it was over the x minutes defined, it would redirect me to the "link is no longer valid" page.