0
を見つけることができませんなぜ私は$http
サービス
getUserPost: function(id) {
var posts = [];
var req = {
method: "POST",
url: "/api/getPost",
data: id
};
によってコントローラに要求を送信しようと、アプリケーションを持っている私はいつも次の取得エラー:
Possibly unhandled rejection: {"data":{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:57196/api/getPost'.","MessageDetail":"No action was found on the controller 'Post' that matches the request."},"status":404,"config":{"method":"POST","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"/api/getPost","data":0,"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json;charset=utf-8"}},"statusText":"Not Found"}
コントローラー:
[RoutePrefix("api")]
public class PostController : ApiController
{
private readonly DataContext _db = new DataContext();
[Route("getPost")]
[HttpPost]
public List<Post> GetPost(string id)
{
var posts = new List<Post>();
if (id != null)
{
posts = _db.Posts.Where(x => x.UzytkownikId == int.Parse(id)).ToList();
}
return posts;
}
誰がどのように私は目を解決することができます知っていますありますか?
は 'データを試してみてください。JSON.stringify({ID:ID})' –