I have to print/display the values of few variables in a MVC view. How can I do this..
public ActionResult DisplayVariables()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
{
//After some process/logic.. variables get assigned values here..
int var1 = xxxxxx;
int var2 = xxxxx;
int var3 = xxxxxx;
int var4 = xxxxx;
}
return View() //I want to display variables values with lables here in this
//view. I already have a view with name "DisplayVariables"
}
Dictionary<String,Object>to the view and iterate over it? Or possibly use reflection and automate the process (assuming you're just stripping properties off theViewBag)