2017-04-21 4 views
0

에 대한 디렉토리를 검색하려고 IIS :내가 속성을 연결하는 데 API 컨트롤러를 만든 빈 경로 속성

[RoutePrefix("fonts")] 
public class InfoController : ApiController 
{ 
    [Route("")] 
    [HttpGet] 
    public IHttpActionResult GetSomeInfo() 
    { 
     return Ok(new { Name = "Some name" }); 
    } 
} 

그리고 "글꼴"라는 프로젝트 루트 폴더를 가지고있다.

나는 요청에 노력하고 때

HTTP Error 403.14 - Forbidden 
The Web server is configured to not list the contents of this directory. 

가 어떻게 컨트롤러 액션을 호출 할이 문제를 해결할 수 있습니다

GET /fonts 

IIS에서 오류가 발생합니다?

업데이트 : 다음은 VS에서 만든 기본 웹 API 구성 인 웹 API 구성 클래스입니다.

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 } 
      ); 
     } 
    } 
+1

이 활성화 라우팅 속성입니다 :

내가 설정했다? – Nkosi

+0

예, 웹 API 구성을 표시하도록 질문을 업데이트했습니다. –

+0

예, 그게 문제를 해결했습니다 –

답변

0

이것은 this page으로 해결됩니다.

routes.RouteExistingFiles = true;