When using TempData, my understanding is that it will keep whatever you put in it around for only one request. So when using TempData to retain data across a redirect (in order to use the Post-Request-Get pattern), isn't it possible that some other request from the user could come into the server in between the response sending the redir...
What is the actual use of TempData collection in asp.net MVC, I need pros and cons of that collection, and when do I need to use it, which views it is shared upon, or any useful information about it, finally if someone can tell me when to use it rather than ViewData?
Thanks in advance
CLOSED as exact duplicate of http://stackoverflow.c...
I'm using the AcceptVerbs method detailed in Scott Gu's Preview 5 blog post for dealing with form entries in ASP.NET MVC:
User gets an empty form via GET
User posts the filled in form via POST to the same Action
The Action validates data, takes appropriate action, and redirects to a new view
So I don't have to use TempData. That sai...
I am using temp data as follow in my controllers - very simple, when there is a problem:
TempData("StatusMessage") = "You have no items set to Auto-Ship."
Then on every page I have a user control as follows:
<div class="error-container">
<% If TempData.ContainsKey("ErrorMessage") Then%>
<script> $('div.error-container').show();</scr...
I would like to have a very lightweight ASP.NET MVC site which includes removing as many of the usual HttpModules as possible and disabling session state. However when I try to do this, I get the following error:
The SessionStateTempDataProvider requires SessionState to be enabled.
I've disabled session state in web.config:
<sessionSt...
There are values I need to pass when I perform redirects. I want to use TempData to accomplish this, but have encountered an issue.
I use a special controller to generate dynamic JavaScripts. For example, there might be a script tag like this:
<script type="text/javascript" src="/Resource/Script/Login.js"></script>
...but there is no...
I'm trying to find a good way to handle the following scenario (I'm still kinda new to this):
A user can register through my site using an RPX/OpenId provider.
Step 1: The user authenticates through a provider. The provider returns a temporary token to one of my action methods.
Step 2: I use the token to grab the user's profile inform...
I have a integer stored in TempData, and it is getting periodically wiped for an unknown reason after 30-60 seconds of browsing around my site.
I have a break point on the place where the value is set and its never being set to null, yet somehow that value in TempData is getting nulled.
Any idea why this is happening?
...
Hi,
I have a controller that sets TempData before returning a view,
public ActionResult Edit(int id, int? order)
{
Route route = new Route();
// Do Work
TempData["Route"] = route;
return View(new FormViewModel(route, obj1, obj2));
}
This view contians a partial view with a link which goes to another action method call...
I've been trying to use CookieTempDataProvider to pass a basic message between a post (entity update) and a get (entity list) using the RedirectToAction method. When using the default TempData implementation this works fine, however when I use the cookie-based version from the MVC Futures project, the TempData dictionary is empty after t...
I'm rendering a common Log-In form using Html.RenderAction, on every page of my site.
If the user enters their details into the text-box and clicks 'Submit', it does a POST to a controller that handles the log in.
If they make a mistake, such as entering an invalid email address, it will populate the ModelState with an error message an...
I am trying to get the hang of MVC framework so bear with me.
Right now, the only thing I'm using the session store for is storing the current logged in user. My website is simple. For this example, consider three domain objects, Person, Meeting, and File. Users can log in and view a "members only" profile of a meeting and can add file...
Is it OK to catch my exceptions in the controller's actions? Is there any better way of doing it? I'm actually catching my exceptions in the controller and using TempData to show a message to the user, but I have a weird feeling about this approach. I've been browsing around but I haven't found anything that suits me.
...
I understand that TempData is designed to work only between a single page request. But I think have a situation I think breaks the intended functionality.
I use Controllers in preference to Handlers for delivering images. I don't now if that is best practice, but it works very well for me. The problem though, is that each call to one of...
I have a small asp.net MVC 1 web app that can store files and create directories in the App_Data directory. When the write operation succeeds, I add a message to the tempdata and do a redirectToRoute. The problem is that the tempdata is null when the action is executed. If i write the files in a directory outside of the web applications ...
Hi! Is there an equivalent for the ViewData/ TempData object in ASP.NET MVC for ASP.NET?
What I wanna do is to keep a Session item only alive for one request.
Thanks in advance!
Edit:
The problem is that I have one view for updating and creating. When the view is in update mode then the session item is filled or it has to be already ...
I'm new to ASP.NET MVC. After working with traditional ASP.NET model for so long, it's taking some time for me to get to understand this model.
I am going through NerdDinner to understand how things work.
So, I have an object that needs to be passed through couple of views. Similar to the article NerdDinner Step 6: ViewData and ViewM...
Can someone post a sample code on how I can access the TempData dictionary object from within the Global.asax.cs.
Thanks in advanced...
...
As a followup to this question, I'm wondering what's happening to my TempData.
Scenario 1:
user logs in
user provides email address
user receives email with validation code
user clicks on validation url
user is validated
success msg is displayed via TempData set in Validate action
Scenario 2:
user logs in
user provides email addr...
I use TempData to keep ModelState during redirects (using MvcContrib technique). This works fine. However, in rare cases, user aborts request and then immediate fires another (e.g. quickly clicks on another menu item). This causes ModelState errors to appear on that page, for which it does not belong.
The problem is that TempData is sto...