在进入ASP.NET MVC Boilerplate中的API操作之前如何处理请求?

时间:2016-05-26 19:48:27

标签: c# asp.net asp.net-mvc asp.net-web-api asp.net-boilerplate

ASP.NET MVC Boilerplate生成的Application Services dynamically API控制器。例如,我需要在请求进入action /方法之前抛出异常。如何处理请求?谢谢!

public class UserAppService : PlatformAppServiceBase, IUserAppService
{
    private readonly IRepository<User, long> _userRepository;

    public UserAppService(IRepository<User, long> userRepository)
    {
        _userRepository = userRepository;
    }

    // handle request before request executes this action
    public async Task<ListResultOutput<UserDto>> GetUsers()
    {           
        var users = await _userRepository.GetAllListAsync();
        return new ListResultOutput<UserDto>(users.MapTo<List<UserDto>>());
    }
}

0 个答案:

没有答案