I was searching around trying to solve a problem I am having with WCF. I am very new to WCF so I wasn\'t sure exactly what was going on.
I am using Visual Studio 20
When you set aspNetCompatibilityEnabled
to true
in your config file, you are stating that your services will participate in the ASP.NET pipeline; so items like ASP.NET session are available. You need to decorate your services appropriately if this is the case, since ASP.NET Compatibility Mode is set to false by default.
So by decorating your service implementation with a RequirementsMode
of Allowed
, you're stating a happy middle ground that basically says your service doesn't care what the aspNetCompatibility
mode is (true or false). If your RequirementsMode
is Required
, then you need to have the config aspNetCompatibilityEnabled
set to true; the opposite is true if your RequirementsMode
is set to NotAllowed
.
(If you go with the happy middle ground of RequirementsMode of Allowed, you can check in your service implementation if aspNetCompatibilityEnabled is enabled or not by checking the static ServiceHostingEnvironment.AspNetCompatibilityEnabled property.)
Silverlight must have a dependency on the ASP.NET pipeline (I'm not a Silverlight developer), which is why you need to enable this compatibility mode in your config and on your services in order for them to be called by Silverlight apps.
Check out MSDN's documentation on this here. The thing to know is that if you don't need ASP.NET pipeline goodies, then you don't need to decorate your services or set the aspNetCompatibilityEnabled setting in your config (they're turned off by default).