1
저는 특성 라우팅을 기반으로 WebApi2 설치에 어려움을 겪었으며 문제가 될 수있는 아이디어가 부족했습니다. 다음 코드는 Visual Studio 2015에서 새로 만든 WebApi 프로젝트입니다. 변경 내용은 없습니다. 단순히 작동하지 않습니다.왜이 webapi2 속성 라우팅이 작동하지 않습니까?
<Error>
<Message>
No HTTP resource was found that matches the request URI 'http://.../services/webapi2/api/dummies/dummymethod'.
</Message>
<MessageDetail>
No type was found that matches the controller named 'dummies'.
</MessageDetail>
</Error>
내가 지금까지 무슨 짓을 : - 모든 것이 잘 보인다 문서에 맞는 뭔가를 놓친 여부를
- 내가 설명서를 확인하신 후
응답은 다음과 말했다.
- 은 내가 유용하게 뭔가를 찾을 수 있는지 여기에 가능한 답을 체크 한 - 내가 사전에 어떤 도움
감사 성공하지 찾은 모든 노력을했다!
DummyController.cs
using System.Web.Http;
namespace WebApi2.Controllers
{
[RoutePrefix("Dummies")]
public class Dummy : ApiController
{
[Route("dummymethod")]
public string Get()
{
return "asdasd";
}
}
}
WebApiConfig.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
namespace WebApi2
{
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/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
}
설치된 패키지 :
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net452" developmentDependency="true" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net452" />
</packages>