I have a function in my file Global.asax.csthat, if necessary, adds a couple of changes to the file Web.config. The file is saved using:
config.Save(ConfigurationSaveMode.Modified);
I recently discovered that it TempDatadidn’t work for my application: it turned out to be empty in the next request. My MCVE :
public ActionResult Foo()
{
TempData["error"] = "testing error passing";
return RedirectToAction("Bar");
}
public ActionResult Bar()
{
throw new Exception(TempData["error"] as string);
}
I added that to mine HomeController, and the visit /Home/Foowill be redirected to /Home/Bar. However, if the above line is config.Saveactive, I get:
Server Error in '/' Application.
Exception of type 'System.Exception' was thrown.
But if I comment on this line, I get:
Server Error in '/' Application.
test error passing
as I originally expected.
( , , , , , , .)
, ?