title: http 404 error when trying to call web api controller action method from .js file
body: <p>I am getting Http 404 error on button click when i inspect element in browser.</p>
  
  <p>There is a wallpost.js file in Scripts folder containing logic for knockout, client side view model and data- binding etc.
  In this file, reference to the WallPost Api controller is given like this---</p>
  
  <pre><code>  var postApiUrl = '/api/WallPost/', commentApiUrl = '/api/Comment/';
  </code></pre>
  
  <p>and on my view page, there is a container for posting and commenting something like this--</p>
  
  <pre><code>    &lt;div class="publishContainer"&gt;
  &lt;textarea class="msgTextArea" id="txtMessage" data-bind="value: newMessage, jqAutoresize: {}" style="height:3em;" placeholder="what's on your mind?"&gt;&lt;/textarea&gt; 
  &lt;input type="button" data-url="/Wall/SavePost" value="Share" id="btnShare" data-bind="click: addPost"/&gt;
  </code></pre>
  
  <p>
  now, references to script folder js files are given like this---</p>
  
  <pre><code>  @section scripts{
    &lt;script src="~/Scripts/jquery.autosize.min.js"&gt;&lt;/script&gt;
    &lt;script src="~/Scripts/knockout-3.3.0.js"&gt;&lt;/script&gt;
    &lt;script src="~/Scripts/wallpost.js"&gt;&lt;/script&gt;
    }
  </code></pre>
  
  <p>First thing i want to clear that autosize.js is working fine on textarea so, i think path to wallpost.js file is correct as it is similar to autosize.js file.
  Now, the problem is i am unable to post the message on button click. I have put the breakpoint at the controller's action method which should be hit on this button click, but thats not get hitted.
  From what i am understanding, i think i am unable to use wallpost.js file in the Scripts folder or the route to call controller's action method is wrong So,there is a problem in reference i think.</p>
  
  <p>The button click should hit the action method but it's not.
  PLzz suggest me what should i try.I can provide more code if required.
  I was following this article.<a href="http://techbrij.com/facebook-wall-posts-comments-knockout-aspnet-webapi" rel="nofollow">http://techbrij.com/facebook-wall-posts-comments-knockout-aspnet-webapi</a></p>
  
  <p>My web-api controller action method is like this----</p>
  
  <pre><code>  namespace WebApp.Controllers
    {
     public class WallPostController : ApiController
     {
      private ApplicationDbContext db = new ApplicationDbContext();
       public HttpResponseMessage PostPost(Post post)
      {
          // post.PostedBy = WebSecurity.CurrentUserId;
          post.PostedBy = User.Identity.GetUserId&lt;int&gt;();
          post.PostedDate = DateTime.UtcNow;
          // post.UserProfile.UserId = WebSecurity.CurrentUserId;
          ModelState.Remove("post.PostedBy");
          ModelState.Remove("post.PostedDate");
          //  ModelState.Remove("post.UserProfile.UserId");
  
          if (ModelState.IsValid)
          {
              db.Posts.Add(post);
              db.SaveChanges();
              // var usr = db.UserProfile.FirstOrDefault(x =&gt; x.UserId == post.PostedBy);
              var usr = db.Users.FirstOrDefault(x =&gt; x.Id == post.PostedBy);
              var ret = new
              {
                  Message = post.Message,
                  PostedBy = post.PostedBy,
                  PostedByName = usr.UserName,
                  //PostedByAvatar = imgFolder + (String.IsNullOrEmpty(usr.AvatarExt) ? defaultAvatar : post.PostedBy + "." + post.UserProfile.AvatarExt),
                  PostedByAvatar = db.Users.Include(s =&gt; s.Files).SingleOrDefault(s =&gt; s.Id == post.PostedBy),
                  PostedDate = post.PostedDate,
                  PostId = post.PostId
                  //  UserId = usr.UserId
              };
              HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, ret);
              response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = post.PostId }));
              return response;
          }
          else
          {
              return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
          }
      }
  </code></pre>
  
  <p>I don't know why its not working. it was working fine when i was using simple membership.now, i want to use it with aspnet identity.</p>