I have simple view in ASP.NET 4:
<form action="GetWeather" method="post">
<input name="city" type="text" />
<input type="submit" />
</form>
<h1>@ViewBag.City</h1>
And simple controller which was supposed to display input from the form on the same page:
public class WeatherController : Controller
{
string cityName = "TBD";
public ActionResult Index()
{
ViewBag.City = cityName;
return View();
}
[HttpPost]
public ActionResult GetWeather(string city)
{
cityName = city;
return Redirect("/Weather/Index");
}
}
After submit I keep getting my "TBD"
string. I couldn't find anything about it, as everything is based on model, which I don't need.