views:

16

answers:

1

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 about 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.

A: 

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?

John Saunders
well, how would IIS throw the error? We want to do it via a key we can turn on and off in code though.
CoffeeAddict
IIS has a setting to "Require" SSL. It's under "SSL Settings" in IIS 7. All of the IIS settings can be changed programmatically.
John Saunders