title: Why can't I use [HttpPost] instead [HttpPost("[action]")]?
body: <p>I don't understand why I need to use <code>[HttpPost("[action]")]</code> instead of <code>[HttpPost]</code>?</p>
  
  <p>If use <code>[HttpPost("[action]")]</code> then the request from angular client hits the controller action.</p>
  
  <pre><code>// POST: api/LeaveRequests
  [HttpPost("[action]")]
  public async Task&lt;IActionResult&gt; PostLeaveRequest([FromBody] LeaveRequest leaveRequest)
  {
      if (!ModelState.IsValid)
      {
          return BadRequest(ModelState);
      }
  
      _context.LeaveRequests.Add(leaveRequest);
      await _context.SaveChangesAsync();
  
      return CreatedAtAction("GetLeaveRequest", new { id = leaveRequest.EmployeeNo }, leaveRequest);
  }
  </code></pre>
  
  <p>But
  If I only put <code>[HttPost]</code> then the request from anglular client does not hit controller action and instead it hits method with the path <code>[HttpGet("{id}")]</code></p>
  
  <p>My MVC route</p>
  
  <pre><code> app.UseMvc(routes =&gt;
              {
                  routes.MapRoute(
                      name: "default",
                      template: "{controller=Home}/{action=Index}/{id?}");
  
                  routes.MapSpaFallbackRoute(
                      name: "spa-fallback",
                      defaults: new { controller = "Home", action = "Index" });
              });
  </code></pre>
  
  <p>my angular http.post</p>
  
  <pre><code>return this.http.post(this._apiUrl, body, options)
      .map(res =&gt; res.json()) // ...and calling .json() on the response to return data
      .catch((error: any) =&gt; Observable.throw(error.json().error || 'Server error'))
      .subscribe();
  </code></pre>