In my previous posts on this topic, I have explained about the following new features in Windows Communication Foundationv 4.5:
- New Features in WCF 4.5 – Part 1
- Simplified Generated Configuration
- Validating WCF Configuration
- New Features in WCF 4.5 – Part 2
- Single WSDL file
- Tooltip and Intellisense Support
Now, here in this WCF Tutorial, I’ll discuss the following new and exciting features in WCF v4.5.
- ASP.NET Compatibility Mode Default Changed
- BasicHttpsBinding
WCF – ASP.NET Compatibility Mode default changed
While working with previous version of Windows Communication Foundation, if we wanted that our WCF request should be treated in the same way as an ASP.NET request, for example, if we wanted to get access to HttpContext, we need to do a couple of steps to enable this feature in WCF. Because, by default, call to a WCF service bypass ASP.NET pipeline as opposite to normal ASMX web services.
Following are the steps we do to enable it: 1. In web.config, set aspNetCompatibilityEnabled to true.
<serviceHostingEnvironment aspNetCompatibilityEnabled=”true” />
2. Add AspNetCompatibilityRequirements attribute to WCF Service with AspNetCompatibilityRequirementsMode set to either Allowed or Required.
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class MyWCFService : IMyWCFService
{
…..
}
public class MyWCFService : IMyWCFService
{
…..
}
In WCF 4.5, AspNetCompatibilityRequirementsAttribute is, by default, set to “Allowed“. So, giving complete control to features in ASP.NET pipeline.
WCF – BasicHttpsBinding
As we have already discussed in earlier parts of this WCF 4.5 Tutorial series that v4.5 has simplified a lot of things for the developers. This new BasicHttpsBinding does the same for us.
BasicHttpBinding is available in Windows Communication Foundation since initial versions. The new BasicHttpsBinding is almost similar to BasicHttpBinding with following two exceptions:
- Default Security mode = Transport
- Default Client Credential Type = None
So, earlier with BasicHttpBinding, declaring transport security based endpoint in WCF is as follows:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name=”BindingConfig1″>
<security mode=”Transport” />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name=”MyWCFService”>
<endpoint address=””
binding=”basicHttpBinding”
bindingConfiguration=”BindingConfig1″
contract=”IMyWCFService”>
</endpoint>
</service>
</services>
</system.serviceModel>
But using WCF 4.5, the same above configuration is simplified as follows:
<system.serviceModel>
<services>
<service name=”MyWCFService”>
<endpoint address=””
binding=”basicHttpsBinding”
contract=”IMyWCFService”>
</endpoint>
</service>
</services>
</system.serviceModel>
Definitely, this cool features simplifies configuration and increases WCF developer productivity.
Top 10 Interview Questions and Answers Series:
- Top 10 WCF Interview Questions
- Comprehensive Series of WCF Interview Questions
- Top 10 HTML5 Interview Questions
- Top 10 ASP.NET Interview Questions
- Comprehensive Series of ASP.NET Interview Questions
- Top 10 ASP.NET MVC Interview Questions
- Top 10 ASP.NET Web API Interview Questions
- Top 10 ASP.NET AJAX Interview Questions