Last active
November 21, 2015 15:11
-
-
Save Tesla9527/f4c20697c4953ea90d9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------------------- | |
Below is code in HomeController.cs | |
----------------------------- | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.Mvc; | |
namespace WebApplication1.Controllers | |
{ | |
public class HomeController : Controller | |
{ | |
public ActionResult Index() | |
{ | |
ViewBag.Countries = new List<string> | |
{ | |
"China", | |
"Japan", | |
"USA" | |
}; | |
return View(); | |
} | |
public ActionResult About() | |
{ | |
ViewBag.Message = "Your application description page."; | |
return View(); | |
} | |
public ActionResult Contact() | |
{ | |
ViewBag.Message = "Your contact page."; | |
return View(); | |
} | |
public ActionResult Foo() | |
{ | |
return View("About"); | |
} | |
} | |
} | |
----------------------------- | |
Below is code in index.cshtml | |
----------------------------- | |
@{ | |
ViewBag.Title = "Home Page"; | |
} | |
@foreach (string country in ViewBag.Countries) | |
{ | |
<li>@country</li> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment