Role Based Access Control for Asmx web service methods

57 Views Asked by At

I have an asmx web service runs with .net 4.5 and it is old project. I aware of there is no Authorize filter for asmx.How to build a structure like that

[MyAuthorize(Roles = "Admin")]
[WebMethod]
public string DisableUser(string UserId)
{ 
  ...
}

[MyAuthorize(Roles = "Admin,HRemployee")]
[WebMethod]
public string GetUserInfo(string UserId)
{ 
  ...
}

I want to append [MyAuthorize... etc. attribute to all method in webservis descripted above. I don't prefer to write code
User.IsInRole("HREmploye") inside each function. Can I add custom attribute to apply role-based permission to all method

0

There are 0 best solutions below