I am sure about your view : -
you have to bind back your model on each request to preserve its value.
Your code would be something like:-
Home Controller
public class HomeController : Controller
{
Class1 cs = new Class1();
[HttpGet]
public ActionResult Index(Class1 model)
{
cs.name = "hi";
if (TempData["A"] == null)
{
TempData["A"] = "B";
}
return View(cs);
}
public ActionResult A(Class1 model)
{
model.age = "hello";
return RedirectToAction("Index", model);
}
}
Index View
<pre>@using Articles.Models
@model Class1
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("A", "Home", FormMethod.Post))
{
<div>
@Html.LabelFor(model => model.name)
@Html.EditorFor(model => model.name)
<br />
@Html.LabelFor(model => model.age)
@Html.EditorFor(model => model.age)
</div>
<div class="options">
<input type="submit" name="save" class="btn btn-success" value="Save" />
</div>
}
</body>
</html>