Reputation: 513
I created empty mvc.net 4 application in visual studio 2012. I added a "Service" controller:
public class ServiceController : Controller
{
//
// GET: /Service/s
public ActionResult Index()
{
ViewBag.text = "EEEE";
return View();
}
}
and I right clicked on ActionResult, and added a view called "Index", and I put in this code:
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<br>
<h2>@ViewBag.Message</h2>
And when I go to link "http://localhost:4376/Service/Index" , all the output I get is: "
Upvotes: 5
Views: 10041
Reputation:
ViewBag.text
is not ViewBag.Message
. Change the view code to
<h2>@ViewBag.text</h2>
or the controller code to
ViewBag.Message = "EEEE";
Upvotes: 7