Я следую учебному пособию на asp.net mvc3 на http://www.asp.net/mvc/tutorials/getting-started-with-mvc3-part3-cs
@{
ViewBag.Title = "Welcome";
}
<h2>Welcome</h2>
<ul>
@for (int i=0; i < ViewBag.NumTimes; i++) {
<li>@ViewBag.Message</li>
}
</ul>
hellowWorldcontroller
using System.Web;
using System.Web.Mvc;
namespace MvcApplication1.Controllers
{
public class HelloWorldController : Controller
{
// GET: /HelloWorld/
/*public void Index()
{
//return "This is my <b>default</b> action...";
return View;
}*/
public ActionResult Index()
{
//ViewBag.Message = "Welcome to ASP.NET MVC!";
return View();
}
//
// GET: /HelloWorld/Welcome/
public ActionResult Welcome(string name, int numTimes = 1)
{
return View();
//return HttpUtility.HtmlEncode("Hello " + name + ", NumTimes is: " + numTimes);
}
}
}
Но похоже, что в cshtml
, он не может запустить код asp.net
, отображать только статическое содержимое, почему?
И cshtml
также не применяются к главной странице MainContent
, есть только обычныетекст без фона и кнопки при запуске приложения, где проблемы?