title: Handle action with invalid Id parameter
body: <p>I am new to ASP.NET MVC and I wonder if the way I handled these cases is the most appropriate.</p>
  
  <p>I have an "ArticleController", which has an action called "Details" (Used the auto-generate edit template).</p>
  
  <p>By default, there is an optional id at the routing table,
  and I want to know how to handle the cases when I don't receive any Id or when I receive a wrong id parameter.</p>
  
  <p>In order to fix it I've wrote this (Note the DefaultValue attribute):</p>
  
  <pre><code>        public ViewResult Details([DefaultValue(0)]int id)
      {
          Article article = db.Articles.Find(id);
  
          if (article == null)
          {
              return View();
          }
          return View(article);
      }
  </code></pre>
  
  <p>And at the view I've wrote this:</p>
  
  <pre><code>@if (Model == null)
  {
      &lt;div&gt;Wrong article id was given.&lt;/div&gt;
  }
  else
  {
      // Handle as a normal case
  }
  </code></pre>
  
  <p>You would have handled these cases differently? If yes, how?</p>