2016-05-15 89 views
2

這裏是我aspBoilerpLate模塊在應用層着訪問的WebAPI出現錯誤

[DependsOn(typeof(TransitCoreModule), typeof(AbpAutoMapperModule))] 
    public class TransitApplicationModule : AbpModule 
    { 
     public override void Initialize() 
     { 
      IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()); 
     } 
    } 

,這裏是我的webapimodule

[DependsOn(typeof(AbpWebApiModule), typeof(TransitApplicationModule))] 
    public class TransitWebApiModule : AbpModule 
    { 
     public override void Initialize() 
     { 
      IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()); 


      DynamicApiControllerBuilder 
       .ForAll<IApplicationService>(typeof(TransitApplicationModule).Assembly, "app") 
       .Build(); 

      Configuration.Modules.AbpWebApi().HttpConfiguration.Filters.Add(new HostAuthenticationFilter("Bearer")); 
     } 
    } 

,這裏是我的AppService服務

public class MeetingAppService : TransitAppServiceBase, IMeetingAppService 
    { 
     private readonly IMeetingManager _meetingManager; 
     private readonly IRepository<Meeting.Meeting, Guid> _meetingRepository; 
     public MeetingAppService (IMeetingManager meetingManager, IRepository<Meeting.Meeting, Guid> meetingRepository) 
     { 
      _meetingManager = meetingManager; 
      _meetingRepository = meetingRepository; 
     } 
     public Task Cancel (EntityRequestInput<Guid> input) 
     { 
      throw new NotImplementedException(); 
     } 

     public async Task Create (CreateMeetingInput input) 
     { 
      var meeting= Meeting.Meeting.Create(AbpSession.GetTenantId(), input.Subject, input.Title, input.Date, input.StartTime, input.EndTime, input.Secretary, input.Description, input.Agenda); 
      await _meetingManager.CreateAsync(meeting); 
     } 

     public async Task<MeetingDetailOutput> GetDetail (EntityRequestInput<Guid> input) 
     { 
      var meeting = await _meetingRepository 
       .GetAll() 
       .Where(m => m.Id == input.Id) 
       .FirstOrDefaultAsync(); 

      return meeting.MapTo<MeetingDetailOutput>(); 

     } 

     public async Task<ListResultOutput<MeetingListDto>> GetList (GetMeetingListInput input) 
     { 
      var meetings = await _meetingRepository.GetAll() 
       .WhereIf(!input.IncludeCanceledMeetings,m=>!m.IsCancelled) 
       .ToListAsync(); 


      return new ListResultOutput<MeetingListDto>(meetings.MapTo<List<MeetingListDto>>()); 

     } 
    } 

當我想訪問http://localhost:6634/api/services/app/meeting/Create 我得到錯誤500消息=發生錯誤。 我找不到調試它的方法 我該如何調試?

回答

0

如果您在瀏覽器中粘貼此URL,那麼您正在嘗試使用GET請求訪問api服務。 ABP API默認使用POST請求。

我建議你試試Postman Chrome Extension來調試api。

-1

有時它不明白請求來自有效的來源。

請嘗試以下代碼服務:

[AbpAuthorize] 

public class MeetingAppService : TransitAppServiceBase, IMeetingAppService 
相關問題