Ich habe TempData für eine lange Zeit verwendet und konfrontiert seltsames Problem für mich. Ich habe Grundszenario:TempData ist nach RedirectToAction im Catch-Block leer. Was könnte der Grund sein?
[HttpPost]
public ActionResult Create(ProductCreateModel newProduct)
{
// create and save product to db
// try upload product to external site
try { UploadProductToEbay(newProduct); }
catch {
TempData["error"] = "error";
return RedirectToAction("Edit", newProduct.Id);
}
...
}
[HttpGet]
public ActionResult Edit(int Id)
{
var error = TempData["error"]; // at this point temp data collection is empty and have no idea why
...
}
Die Ausgabe erfolgt beim Upload schlägt fehl, und return RedirectToAction("Edit", newProduct.Id);
Zeile ausgeführt wird. Was könnten nicht sehr offensichtliche Gründe für den Verlust von Temp Data-Werten sein?
UPDATE: Wenn ich
TempData["error"] = "error";
RedirectToAction(...);
außerhalb des catch
Block funktioniert alles einwandfrei, Temperatur-Datenwert zu Edit
Aktion übertragen wird.
mögliche Antwort http://stackoverflow.com/questions/173159/difference-between-viewdata-and-tempdata –
@ user1799320, gibt es keine passende Antwort für mich. – Dmytro
@Dmytro - hast du die Antwort gefunden, ähnliches Problem –