Search code examples
c#asp.netasmx

Authentication in asmx service


I am using ASP.NET with an asmx service for data access towards my SQL database.

The servie is called both Client and backend.

The site is going to be used both our internal staff and for our customers.

There is some methods in the asmx service that I would like to to disable access to if they are not authenticated. I really do not want to write a lot of duplicate code in the every method to check for this.

is there any generic way or better? Thanks.


Solution

  • WCF or Web API seem to be the better solutions to grant access to some resources in your database than ASMX, since that feature has been phased out some time already.

    If you use WebAPI, you can use the Authorize attribute that will prevent access to a certain method if the user isn't authorized to. WCF doesn't have this out of the box, but there are workarounds for this.