无法访问aspnetboilerplate错误500消息中的webapi发生错误

时间:2016-05-15 14:10:36

标签: asp.net-boilerplate

这是我在Application Layer

中的aspBoilerpLate中的模块
 [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消息=发生了错误。 我找不到调试它的方法 我该怎么调试呢?

2 个答案:

答案 0 :(得分:0)

如果您在浏览器中粘贴此网址,那么您正尝试使用GET请求访问api服务。 ABP api默认使用POST请求。

我建议您尝试Postman Chrome Extension来调试api。

答案 1 :(得分:-1)

有时它不理解请求来自有效的来源。

请在服务中尝试以下代码:

[AbpAuthorize]

public class MeetingAppService : TransitAppServiceBase, IMeetingAppService