2016-12-05 6 views
1

내 웹 API가 제대로 작동하지만 영역 폴더에 동일한 코드를 쓸 때 작동하지 않습니다.하위 폴더에서 웹 API가 작동하지 않습니다.

public static class WebApiConfig 
    { 
     public static void Register(HttpConfiguration config) 
     { 
      config.Routes.MapHttpRoute(
       name: "FeatureA", 
       routeTemplate: "FeatureA/api/{controller}/{id}", 
       defaults: new { id = RouteParameter.Optional } 
     ); 

      config.Routes.MapHttpRoute(
       name: "DefaultApi", 
       routeTemplate: "api/{controller}/{id}", 
       defaults: new { id = RouteParameter.Optional } 
     ); 
     } 
    } 
+1

'작동하지 않는다 '는 것은 무슨 뜻입니까? 오류가 있습니까? –

+0

404 페이지를 찾을 수 없습니다. –

답변

2

당신은 당신의 지역 폴더 년대 "YourHubNameAreaRegistration"클래스에서 라우팅 정보를 넣을 필요가있다. RegisterArea 메서드에 들어가서 다음과 같이 보입니다 :

public override void RegisterArea(AreaRegistrationContext context) 
    { 
     context.MapRoute(
       "Hub_default", 
       "api/Hub/{action}/{id}", 
       new { controller = "Hub", action = "Index", id = UrlParameter.Optional } 
     ); 
    } 
+0

답변 해 주셔서 감사합니다. –

관련 문제