0
これは恐らく言葉の問題です。これは私の最初のWeb APIです。私のコントローラと私のモデルは、私のコントローラに3つのメソッド、string [] Apples string [] Get Judgment GetJudgmentByStateCaseIdがあります。私は、次のURLを使用してそれらの呼び出しを試みているが、すべての結果はGet()データから来る。任意のメソッドを呼び出すと、メソッドの代わりにGet()の結果が返されます
- /API /判断
- /API /りんご
- /API/GetJudgmentByStateCaseId
`JudgmentController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebApplicationsWData.Models;
namespace WebApplicationsWData.Controllers
{
public class JudgmentController : ApiController
{
public string[] Apples()
{
return new string[]
{
"as","B"
};
}
public string[] Get()
{
return new string[]
{
"as","C"
};
}
public Judgment GetJudgmentByStateCaseId(string State, string CaseId)
{
Judgment judgement = new Judgment
{
CaseId = "1",
State = "MeVMe"
};
if (judgement == null)
throw new HttpResponseException(HttpStatusCode.NotFound);
return judgement;
}
}
` Judgment.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace WebApplicationsWData.Models
{
public class Judgment
{
[Required]
public string State { get; set; }
[Required]
public string CaseId { get; set; }
}
}
01この質問は、ASP APIの複数の方法をサポートするためにどのような表現されなければならないので
そして、ここでは私のRouteConfig
namespace WebApplicationsWData
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
}
参照を[この](http://stackoverflow.com/a/35344367/304683) – EdSF