0

In ASP.NET MVC Boilerplate API Controllers generating from Application Services dynamically. For example I need to throw an exception before request go into the action/method. How handle request? Thanks!

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>>());
    }
}
Grigor Aleksanyan
  • 540
  • 1
  • 6
  • 19
  • Have an http module that just fires your validation logic and raises exceptions eariler in the pipeline than the mvc handler runs. – Wiktor Zychla May 26 '16 at 19:52
  • I try with validation, but if no authorized user, the request just rejected before handling. I look at the sources of Boilerplate, but theirs authorization handler is internal class, so I can't change or override it. – Grigor Aleksanyan May 26 '16 at 19:55

0 Answers0