title: List <string> to display in Partial MVC 3-Razor View -AJAX call
body: <p>I know this would be easy for most of you folks, but I am new to this .net stuff.
  Trying to pass a list of string List to partial view, which is called with jquery load method</p>
  
  <pre><code>$('#tree-res').load("@Url.Action("GetTreeView" , "TreeView" )");
  </code></pre>
  
  <p>and i am calling this view from controller </p>
  
  <pre><code>public PartialViewResult GetTreeView()
      {
          List&lt;string&gt; list=new List&lt;string&gt;();
          list.Add("Something");
          return PartialView("TreeView",list);
      }
  </code></pre>
  
  <p>Now, how to iterate over this list and display it in TreeView.cshtml</p>
  
  <p>following throws errors :</p>
  
  <pre><code>@model List&lt;string&gt;
  @foreach (var item in Model)
  {
  }  
  </code></pre>
  
  <p>Thanks</p>
  
  <p>Following is stack trace:</p>
  
  <pre><code>Line 1:  @model List&lt;string&gt;
  Line 2:  @foreach (var item in Model)
  Line 3:  {
  Line 4:  }           
  </code></pre>
  
  <blockquote>
  <pre><code>Source File: c:\scm\branches\Quest\Views\TreeView\TreeView.cshtml 
  </code></pre>
    
    <p>Line: 2</p>
  
  <pre><code>Stack Trace:
  
  [NullReferenceException: Object reference not set to an instance
  </code></pre>
    
    <p>of an object.]
        ASP._Page_Views_treeview_TreeView_cshtml.Execute() in
    c:\scm\branches\Quest\Views    \TreeView\TreeView.cshtml:2
        System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207
        System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81</p>
    
    <p>System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext
    pageContext, TextWriter writer, WebPageRenderingBase startPage) +88
        System.Web.Mvc.RazorView.RenderView(ViewContext viewContext,
    TextWriter writer, Object instance) +220
        System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext
    viewContext, TextWriter writer) +115
        System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext
    context) +303</p>
    
    <p>System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext
    controllerContext, ActionResult actionResult) +13</p>
    
    <p>System.Web.Mvc.&lt;>c_<em>DisplayClass1c.b</em>_19()
    +23</p>
    
    <p>System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter
    filter, ResultExecutingContext preContext, Func`1 continuation) +260
        ....</p>
  </blockquote>