title: Understanding [HttpPost], [HttpGet] and Complex Actionmethod parameters in MVC
body: <p>I am very very new to MVC the design-pattern and also the Framework. I am also not extremely well- versed in fundamentals of ASP.NET Forms. However, I do understand the basics of web development and HTTP Post and GET as well.</p>
  
  <p>Now, I have been going through some MVC tutorials and I though I was getting a good hold of how MVC the pattern works and also how "Routing Engine" works. Then suddenly I came across a code which looks like folloing:</p>
  
  <pre><code>public class HomeController : Controller
  {
      public ActionResult Index()
      {
          return View(new MyViewModel());
      }
  
      [HttpPost]
      public ActionResult Index(MyViewModel model)
      {
          return Content("Thanks", "text/html");
      }
  }
  </code></pre>
  
  <p>I have few questions looking at it:</p>
  
  <ul>
  <li>My understanding of routing engine was that the control is passed to <strong>a particular</strong> ActionMethod based on URL and normally URL are basically Controller/ActionMethod/Id kind where paramter to action menthod are rather Primitive types. In this example above what kind of URL would it take to call " </li>
  </ul>
  
  <blockquote>
    <p>public ActionResult Index(MyViewModel model)?"</p>
  </blockquote>
  
  <p>Since NyViewModel is a complex type, you can not pass it as part of URL. How can you call it?</p>
  
  <ul>
  <li>Why is this second method adorned with [HttpPost] when the first method does not require any attributes? Are there any guidelines on when to use [Http] attributes and when not?</li>
  </ul>
  
  <p>I think I am missing a big pice in the puzzle and both the questions are interrelated. However, need some help in making sense with the relationship</p>