title: mvc4 razor return empty model on httpget
body: <p>I would like to return empty model on httpget in a mvc4 razor view. I'll be fetching the model on httppost once the user will select the value from a dropdownlist.
  This is what I have:</p>
  
  <pre><code> [HttpGet]
          public ActionResult AddNewAgent()
          {                   
              var modelAgentt = _fe.Agents.Take(1);           
              SelectList sl = new SelectList((from s in _aa.Agent.ToList() select new {COUNTER = s.COUNTER, FullName = s.LASTNAME + ", " + s.FIRSTNAME}), "COUNTER", "FullName", null);
              ViewBag.Agent= sl;
              return View(agg);
          }
  </code></pre>
  
  <p>Then at HttpPost I have:</p>
  
  <pre><code>[HttpPost]
          public ActionResult AddNewAgent(int? LamcomAgents)
          {    
              var modelAgent = _fe.Agents.Take(10);
              SelectList sl = new SelectList((from s in _aa.Agent.ToList() select new { COUNTER = s.COUNTER, FullName = s.LASTNAME + ", " + s.FIRSTNAME }), "COUNTER", "FullName", null);
              ViewBag.Agent= sl;
              if (LamcomAgents != null &amp;&amp; LamcomAgents != 0)
              {
                  return View(modelAgent);                
              }
              return View(modelAgent);            
          }
  </code></pre>
  
  <p>The proper linq query is not still included in the httppost action but I'll do that later, i just want to know how I can pass nullable model for the httpget at the first run without getting error in the view.
  This is what I have in the view:</p>
  
  <pre><code>@model IEnumerable&lt;Company.Agents&gt;
  
  @{
      ViewBag.Title = "AddNewAgent";
  }
  
  &lt;h2&gt;Add New Agent&lt;/h2&gt;
  
  @using (Html.BeginForm()) {
      @Html.AntiForgeryToken()
      @Html.ValidationSummary(true)
  
      &lt;fieldset&gt;
          &lt;p&gt;Agents in System @Html.DropDownList("Agent", String.Empty)&amp;nbsp;&amp;nbsp; &lt;input type="submit" name="Get Agent" value="Get Agent" title="Get Agent" id="btnGetAgent" /&gt;&lt;/p&gt;
          &lt;legend&gt;Agents&lt;/legend&gt;      
     &lt;table&gt;       
                      &lt;tr&gt;
                          &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.A_FirstName)&lt;/th&gt;
                          &lt;th&gt;&lt;/th&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
  
                      &lt;/tr&gt;              
              @foreach(var item in Model)
              {
                  &lt;tr&gt;&lt;td&gt;
                 @Html.DisplayFor(modelItem =&gt; item.A_FirstName)
                      &lt;/td&gt;&lt;/tr&gt;
              }
                  &lt;/table&gt;
  
          &lt;p&gt;
              &lt;input type="submit" value="Create" /&gt;
          &lt;/p&gt;
      &lt;/fieldset&gt;
  }
  
  &lt;div&gt;
      @Html.ActionLink("Back to List", "Index")
  &lt;/div&gt;
  
  @section Scripts {
      @Scripts.Render("~/bundles/jqueryval")
  }
  </code></pre>
  
  <p>Thanks in advance, Laziale</p>