Search code examples
wcfwcf-rest

How to enforce one method in WCF Rest to be called via https, while others can be called over http


Is there a way in a WCF Rest Service implementation to require one method be called over https, while allowing others to be called over http or https without having to define two service endpoint bindings? I want to be able to do something in my service implementation such as:

if (CalledOverHttps()) {
   //Do Stuff
} else {
   throw new WebOperationException("Nice try buddy");
}

Thanks in advance!


Solution

  • I handled this with IIS, and requiring https on a virtual directory. So in my directory structure i have:

    non secured: http://foo.com/someservice.svc

    secured: https://foo.com/secure/someservice.svc

    and if you tried http://foo.com/secure/someservice.svc, an appropriate 500 error is thrown by IIS.