title: Problem with Html.Action call to action with [HttpGet] attribute
body: <p>I have just encountered a strange problem. I have fixed it, but I am hoping that you may be able to help me better understand what actually went wrong. I'll start with an explanation of what happened. The problem concerns a simple MVC3 RC1 app.</p>
  
  <p>In my app's master page there is a call to an action on a controller to render a login-form:</p>
  
  <pre><code>@Html.Action("LoginForm", "Account")
  </code></pre>
  
  <p>The action method on the AccountController class returns a PartialViewResult containing the login-form.</p>
  
  <pre><code>public PartialViewResult LoginForm()
  {
      return PartialView();
  }
  </code></pre>
  
  <p>Today I made a change to this action method and attributed it with the HttpGetAttribute like so:</p>
  
  <pre><code>[HttpGet]
  public PartialViewResult LoginForm()
  {
      return PartialView();
  }
  </code></pre>
  
  <p>This is what caused problems. However, the problems only existed in one particular scenario - and this is what baffles me. When <em>posting</em> a form to a controller everything would work just fine provided that the controller action then returned a <em>RedirectToRouteResult</em>. If the action just returned a <em>ViewResult</em> (to its default view), my Http404 error handling would kick in and loop forever.</p>
  
  <p>I have implemented 404 error handling in a manner very similar to what is described in the third answer to this question: <a href="https://stackoverflow.com/questions/619895/how-can-i-properly-handle-404s-in-asp-net-mvc">Requirements for 404</a>. If you don't want to read that post, in simple terms I override the HandleUnknownAction method on my base controller class, and in that method I instantiate an instance of my ErrorController class and call Execute on it, passing it an instance of RouteData:</p>
  
  <pre><code>protected override void HandleUnknownAction(string actionName)
  {
      // If controller is ErrorController dont 'nest' exceptions
      if (this.GetType() != typeof(ErrorController))
          this.InvokeHttp404(HttpContext);
  }
  
  public ActionResult InvokeHttp404(HttpContextBase httpContext)
  {
      IController errorController = DependencyResolver.Current.GetService&lt;ErrorController&gt;();
  
      var errorRoute = new RouteData();
      errorRoute.Values.Add("controller", "Error");
      errorRoute.Values.Add("action", "Http404");
      errorRoute.Values.Add("url", httpContext.Request.Url.OriginalString);
      errorController.Execute(new RequestContext(httpContext, errorRoute));
  
      return new EmptyResult();
  }
  </code></pre>
  
  <p>All the ErrorController does is log the error and return a view with a friendly error message. Well, that's how it <em>should</em> work. But in this case the error handling would enter into an infinite loop where the AccountController (to which my form was posted) would invoke the HandleUnknownAction over and over and over again.</p>
  
  <p>There was nothing in the error logs to indicate what had gone wrong (I think I log just about <em>everything</em>) - which was also strange. So I figured that if removed the HandleUnknownAction method from my controller base class maybe something else would be revealed. And it was:</p>
  
  <p><strong>2010-12-10 19:11:47,956 [4] ERROR Infrastructure.Log4NetAuditor [System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'. ---> System.Web.HttpException (0x80004005): Execution of the child request failed. Please examine the InnerException for more information. ---> System.Web.HttpException (0x80004005): A public action method 'LoginForm' was not found on controller 'Cdo.Web.Controllers.AccountController'.</strong></p>
  
  <p>What the? When I saw this I remembered that I'd put the HttpGetAttribute on this method - so I promptly removed it... and order was restored. I am happy to have discovered <em>what</em> caused this - but I remain in the dark on <em>why</em> it happened. If you are able to help me shed some light on this I'd be much obliged. Why would the HttpGetAttribute make a difference here?</p>