MVC :: Steps To Make TempData Durable Across Web Server?
Jun 5, 2010
We 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?
I am brand new to ASP.NET - I actually just finished my first week long class on it last week and now I am back at work trying to use what I learned in class.
On the last day of class we were taught how to deploy an ASP Project to our production server using a wizard in Visual Studio and it worked great. Now, in the real world, I have a development environment on my desktop at work that matches exactly the production environment on my production server. If I make a change to the Default.aspx file on my desktop, do I have to deploy it to my production server using the deployment wizard in Visual Studio or can I just copy the Default.aspx file from my desktop to the production server and replace it? I just don't want to mess up the Project Files and I am not sure if I will if I don't move over everything.
tempdata 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
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.
I 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.
The 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.
I'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 know its a common question. But I want to share something. Actually I am working on e-commerce portal. It consists of 32000 products with around 2500 categories. I used 3-tier architechture for this project.Everyting is coming using stored procedures. I used master pages as well.But still I am fighting with the performance issue. Can anyone pls tell me some usefull steps to increase the speed of the website.Its taking ages to load the pages. please look at the site
I have an asp:wizard control that contains five WizardSteps. All of these steps have form controls, and most of these controls have validators. When the user steps through the wizard with the next and previous buttons everything is working great, and validation triggers as it should. However, if the user chooses to navigate the wizard using the links in the SideBar, he or she could skip some of the steps. When the last page is submitted (which is a summary page) there might be controls in the wizard that are invalid.
What I want to do is to check the state of all controls (or run all validators) when the user clicks the finish button, or when the user enters the summary page. I have made an attempt to run all the validators in the FinishButtonClick event by doing this:
[code]....
But when I do this every validator claims that they are valid. I have also tried to set all controls to Visible = true; prior to this code block, but this has no effect. what could be wrong? Or is it a better way of doing this, maybe a native function to the wizard control that I'm missing?
I am not sure how to write soap exception. What are the steps to write soapException. Somebody can explian?
<WebMethod(MessageName:="get_output_information")> _ Public Function get_output_information (ByVal tran_id As Object) As DataSet Try 'do some code here 'do some code here Return ds1 Catch ex As Exception Throw New ArgumentException("An Error occurred while processing output information.") End Try End Function
I was wondering, in MVC normally we can include validation in the model. Plus, we can add our own custom error in the control using the ModelState.AddModelError.However, it is okay to call ModelState.AddModelError after we called ModelState.IsValid ?
In others words, if i wanna :
1- Check if cart is not empty.
2- Check if the shipping details are valid.
3- Doing the transaction by creditcard.
4- Check if its a success.
5- If its a success Submit the order.
Is this controller code okay, does it fellow conventions ?Is there a better way to do thoses steps ?
--- public ActionResult CheckOut(Cart cart, ShippingDetails shippingDetails, CreditCard creditCard)[code]....
Background - I've started with a VS2010 dynamic data project, but now I want to add some other custom pages based on MVC to it. Question - What is the minimum I would need to do to get this non-MVC project to look/act like an MVC project?
To complete an order, I need to code the following steps one by one.
1) update order table, tOrder
2) update customer order history table, tCustomer
3) update shipment table, tShip
4) send an confirfation email
The problem is sometime due to unknown reason, after step 2), program can not finish step 3) and 4). Since tOrder and tCustomer table was updated, how to back to their data before update?
I have a CreateUserWizard with three Wizard steps and one CreateUserWizardStep. The first two are accessible from the code behind by ID. The third and fourth are not! If I comment out the references to these two steps in the code behind the page runs fine. I have triple checked the variable names and everything is fine. Everything that should have a runat="server" does, everything is enabled, all of that good stuff.
why some steps in the same CreateUserWizard may not be visible from the code behind and others are?
I am trying to add wizard steps dynamically in code-behind but keep getting an exception
"ActiveViewIndex is being set to '0'. It must be smaller than the current number of View controls '0'. For dynamically added views, make sure they are added before or in Page_PreInit event."
I found I have some fundamental error in my building, since I got this error after trying to build the simplest wizard in a new web-site just opened...
I would like to know what are the basic steps involved in setting up your application to able to read data from another application. Then take that data and modify it and send it back to the application. The data being read will have over 100 fields.... what is the most efficent way to store them? Put them in a class object?