This is how it is done. Please pay attention to my comments in the code:
Controller/Model:
public class StudentModel
{
public string StudentData { get; set; }
}
public class HomeController : Controller
{
public string PassDataToMe(StudentModel model)
{
return model.StudentData;//no view defined
}
public ActionResult ShowData(int? ID)
{
var stdDef = "stdDef";
var model = new StudentModel
{
StudentData = stdDef
};
return View(model);
}
[HttpPost]
//!changed this to studentmodel
public ActionResult ShowData(StudentModel model)
{
//this is how you pass limited bytes of data that are not encrypted
return RedirectToAction("PassDataToMe", model);
}
View:
@model Testy20161006.Controllers.StudentModel
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>ShowData</title>
</head>
<body>
<div>
@using (Html.BeginForm())
{
@Html.LabelFor(r => r.StudentData);
@Html.TextBoxFor(r=>r.StudentData);
<input type="submit" value="submit" />
}
</div>
</body>
</html>