.net フレームワーク 4.5 を使用して、mvc4 と共に Visual Studio 2012 をインストールしました。今、属性の書き込みで webapi2 を使用したいのですが、hlep ページにすべてのエンドポイントを適切に表示したいと考えています。
私のソリューションでは、新しいmvc4ベースのemtpyプロジェクトを追加し、nugetを使用してmvc5にアップグレードしてから、webapi2パッケージをインストールしました。最後に、webapi2 のヘルプ パッケージをインストールしました。
現在、routeprefix を使用すると、ヘルプ ページにコンテンツが表示されず、ブラウザで webapi エンドポイントにアクセスしようとすると、次のエラーがスローされます。
<Error>
<Message>
No HTTP resource was found that matches the request URI 'http://expressiis.com/api/v1/'.
</Message>
<MessageDetail>
No type was found that matches the controller named 'v1'.
</MessageDetail>
</Error>
namespace WebApi.Controllers
{
[RoutePrefix("api/v1")]
public class SubscribersController : ApiController
{
// GET api/<controller>
[Route("")]
[HttpGet]
public IQueryable<string> Get()
{
return new string[] { "value1", "value2" }.AsQueryable();
}
}
}