這裏找到API方法傾斜度爲啓動ruinning控制器方法在Web應用程序:網絡從Web應用程序
public ActionResult PaginationOfBooks(string _title, string _author, string _description, string _publisher)
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:57752");
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = client.GetAsync("api/Book/GetBooks").Result;
休息並不重要呢。其實在這一點上,在調試模式下我期待切換,在使用Web應用程序相同的解決方案,GetBooks方法我在這個方法的第一線破發點的WebAPI項目..這裏是結果的內容:
StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
我的網絡ABI項目:
public ActionResult GetBooks(string _title, string _author, string _description, string _publisher)
{
var draw = 1;
...
的WebAPI配置:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/Book/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Formatters.Remove(config.Formatters.XmlFormatter);
config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
}
}
我怎麼能得到這個網絡API請求?
[ASP.NET Web API中可選參數的屬性路由]的可能重複(http://stackoverflow.com/questions/22388452/attribute-routing-with-optional-parameters-in-asp-net-web- api) – Eris