I just did a simple Page in MVC where i was getting an error of parser. My code was everything fine. i just need some one what would cause this error. I know it's a simple thing but i had been getting this error
Controller:HomeController public ActionResult Index()
{
ViewBag.Countries = new List<string>()
{
"India",
"Japan",
"UK",
"USA"
};
return View();
}
My View:Index.cshtml <h2>Countries List</h2>
<ul>
@foreach (string strCountry in ViewBag.Countries)
<li>
@strCountry
</li>
</ul>
My Error appears as :
Parser Error Message: Expected a "{" but found a "<". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed:
Join Hands Change lives
Thanks & Regards
Straight Edge Society