开发者

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

开发者 https://www.devze.com 2022-12-18 07:48 出处:网络
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 bind

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 bindi开发者_开发技巧ngs? 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!


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.


I'm not entirely sure, but I believe you can configure it in the bindings.

I have to look it up, though.

0

精彩评论

暂无评论...
验证码 换一张
取 消