【发布时间】:2016-03-10 08:02:25
【问题描述】:
我在 Visual Studio 2012 中创建了空的 mvc.net 4 应用程序。 我添加了一个“服务”控制器:
public class ServiceController : Controller
{
//
// GET: /Service/s
public ActionResult Index()
{
ViewBag.text = "EEEE";
return View();
}
}
然后我右键单击 ActionResult,并添加了一个名为“Index”的视图,然后我输入了以下代码:
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<br>
<h2>@ViewBag.Message</h2>
当我去链接 "http://localhost:4376/Service/Index" 时,我得到的所有输出都是: "
Index
,并且没有显示“EEEE”文本。我做错了什么?【问题讨论】:
标签: c# asp.net-mvc view controller