title: C# MVC 4 RAZOR - JSON return List from Controller to View using @foreach
body: <p>I am new in MVC 4 Razor as I am going deeper into it I am thinking that, is it possible to pass a JSON list in ActionResult to View?</p>
  
  <p>Here is my code in Controller:</p>
  
  <pre><code>public ActionResult Index()
  {
      User _user = db.Users.ToList();
      return Json(_user , JsonRequestBehavior.AllowGet);
  }
  </code></pre>
  
  <p>Here is my code in View: I want to place my JSON in <code>@foreach</code></p>
  
  <pre><code>@model IEnumerable&lt;MVC_AjaxActionLink.Models.User&gt;
      &lt;body&gt;
          &lt;input id="txtUser_Idx" type="text" /&gt;
          &lt;input id="btnSend" name="btnSend" type="button" value="Search" /&gt;
          &lt;div id="User_Result"&gt;
              @foreach (var item in Model)
              {
                  &lt;table&gt;
                      &lt;tr&gt;
                          @Html.HiddenFor(modelItem =&gt; item.User_Idx)
                          &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.LoginName)&lt;/td&gt;
                          &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.FirstName)&lt;/td&gt;
                          &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.MiddleInitial&lt;/td&gt;
                          &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.LastName)&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;
              }
          &lt;/div&gt;
      &lt;/body&gt;
  </code></pre>
  
  <p>Here is my SQL table:</p>
  
  <pre><code>USE [Sample_db]
  GO
  
  CREATE TABLE [dbo].[Users](
      [User_Idx] [bigint] IDENTITY(1,1) NOT NULL,
      [LoginName] [nvarchar](20) NOT NULL,
      [FirstName] [nvarchar](50) NOT NULL,
      [MiddleInitial] [nvarchar](10) NULL,
      [LastName] [nvarchar](50) NOT NULL,
   CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
  (
      [User_Idx] ASC
  ))
  
  GO
  </code></pre>