Where to check for secure connection with Web Service on any type of call to the Service
We want any calls to our .asmx web service to be made by the client from https. If not, throw an error.
I've setup the following method in my .asmx:
private bool IsSecureConnection()
{
return HttpContext.Current.Request.IsSecureConnection;
}
Question is, do I have to call this in every method and throw or is there a better way to call this, lets say once so that any developer adding methods to this .asmx don't have to worry abo开发者_StackOverflowut calling this check.
Basically I'm looking for some sort of event that I can hook into that when any call is received to this web service, it calls IsSecureConnection and if false, throw an exception.
ASMX web services have no feature that would do what you want.
I suppose you could implement a SoapExtension
.
Better still, can't you just do this in the IIS setup?
精彩评论