October 2011 - Posts
If you are not familiar with our user group, the Israeli WDC user group is a meeting place for web developers, designers, and architects, where we discuss new and existing web technologies, best practices in web development, and any other interesting stuff that relates to the web world. The user group is managed by Gal Kogman and yours truly, with the support of Microsoft Israel.
This is just a short list of things we talked about in previous meetings:
- ASP.NET MVC
- Win8, HTML5, and JS libraries
- jQuery mobile framework
- Beyond Visual Studio 2010 – Lightswitch, NuGet, IIS Express …
- Javascript and jQuery tricks
- Facebook for developers
- Rich application for the browser – EF, WCF, Ajax, and jQuery
You can read more about the user group on our Microsoft page (a bit outdated), and for the latest news and information, I suggest you visit our Facebook page.
So what’s the purpose of this post, you ask? I’m writing this post to let you know that we are always looking for potential speakers - the field of web development is very vast, and many of us deal with all sorts of web technologies and techniques, so if you think you have worked with a special technology you want to share with the community by presenting it in one of the meetings, please let me know by email or by writing in our Facebook wall. You don’t need to be an experienced speaker to present at the meetings, just make sure you don’t have stage freight beforehand
.
This is the eighth post in the WCF 4.5 series. This post continues the previous posts on web-hosting features. This post is about the ASP.NET compatibility mode default change of WCF 4.5.
Previous posts:
1. What’s new in WCF 4.5? let’s start with WCF configuration
2. What’s new in WCF 4.5? a single WSDL file
3. What’s new in WCF 4.5? Configuration tooltips and intellisense in config files
4. What’s new in WCF 4.5? Configuration validations
5. What’s new in WCF 4.5? Multiple authentication support on a single endpoint in IIS
6. What’s new in WCF 4.5? Automatic HTTPS endpoint for IIS
7. What’s new in WCF 4.5? BasicHttpsBinding
Normally, a WCF service hosted under IIS works side-by-side with ASP.NET – they share some of the pipeline, they have the same application domain, but work quite independently of each other when it comes to the HTTP context (authorization, context, session, etc…). This is the default behavior of WCF.
However, you can change the default behavior of WCF and set it to ASP.NET compatibility mode – this allows WCF and ASP.NET to share most of the pipeline, and have the same HTTP context. This has some advantages and some disadvantages (such as the problem of ASP.NET sessions and blocking WCF calls).
To make WCF use the ASP.NET compatibility mode you need to do the following two changes:
1. Enable ASP.NET compatibility mode for the hosting environment in your web.config:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
2. Set each of your services to support the compatibility mode, by adding the AspNetCompatibilityRequirements attribute.
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
You can read more about WCF and ASP.NET on MSDN.
So what has changed in WCF 4.5?
In WCF 4.5 the default behavior of WCF is to support the ASP.NET compatibility mode automatically. This is achieved by the following changes:
1. In the WCF Service Application project template, the aspNetCompatibilityEnabled attribute was added to the serviceHostingEnvironment element, and it is set to true by default.
2. The default value of the AspNetCompatibilityRequirements attribute has changed from NotAllowed to Allowed. Without this changed default, you would have needed to manually add the attribute to every new service. This is noticeable in the attribute’s documentation:
WCF 4 - http://msdn.microsoft.com/en-us/library/system.servicemodel.activation.aspnetcompatibilityrequirementsattribute.requirementsmode(v=VS.100).aspx
WCF 4.5 - http://msdn.microsoft.com/en-us/library/system.servicemodel.activation.aspnetcompatibilityrequirementsattribute.requirementsmode(v=VS.110).aspx
ASP.NET compatibility mode is very useful if you need to use share information between your ASP.NET application and WCF service in regards to the HTTP context, session, or user authorization, but be careful of the concurrency problem that occurs when sharing session state between WCF and ASP.NET.
Expect more on ASP.NET and WCF in next posts, so stay tuned. You can also follow me on Twitter (@IdoFlatow) to get updates as soon as new posts are published.
The RTM of .NET 4.5 is still to come, and I assume many of you are still adjusting to WCF 4. If you want to learn more about the new features of WCF 4, come to my session at Visual Studio Live! 2011 in Orlando (December 5-9).
Today I had my WebDev session about the new technologies related to web development:
- ASP.NET MVC 3
- Razor view engine
- jQuery
- NuGet
- IIS Express 7.5
I enjoyed the session very much, and by the amount of tweets it looks like I wasn’t the only one.
I hope no one got hurt from my flying balls 
You can download the session’s slides and the two demos I showed from here: http://bit.ly/vslive-2011-redmond
I’m off to San-Francisco tomorrow for the North-America MCT summit. Visual Studio Live – thanks for having me, I will see you all again in VS Live Orlando in December.
Yesterday I had my WCF 4 session in VS Live, where I showed some of the new features of WCF 4, including:
- Configuration simplification
- IIS hosting features
- WebHttp improvements
- Routing services
- Discovery services
I also talked a bit about some other new WCF 4 features such as the DataContractResolver type, the new ReceiveContext API for MSMQ bindings, Monitoring WCF with ETW and PerfMon, the new binary stream encoder, and the new throttling defaults.
Those of you who stayed till the end also heard about some of the new features that will be in WCF 4.5.
So if you’ve missed the session, had to step outside for an important call, or you just want to try out the samples I showed, you can go ahead and download the slides and samples from here: http://bit.ly/vslive-2011-redmond
This is the seventh post in the WCF 4.5 series. In previous posts we’ve examined two new security features of WCF 4.5 and IIS – multiple client credentials support, and default HTTPS endpoint support, both new features are IIS-specific (or to be more exact, web hosting specific). In this post we will look into a new security configuration option in WCF 4.5 – the BasicHttpsBinding.
Previous posts:
1. What’s new in WCF 4.5? let’s start with WCF configuration
2. What’s new in WCF 4.5? a single WSDL file
3. What’s new in WCF 4.5? Configuration tooltips and intellisense in config files
4. What’s new in WCF 4.5? Configuration validations
5. What’s new in WCF 4.5? Multiple authentication support on a single endpoint in IIS
6. What’s new in WCF 4.5? Automatic HTTPS endpoint for IIS
Transport security is supported in WCF since day 1, and you can configure it by setting the security mode of your binding:
<bindings>
<basicHttpBinding>
<binding name="secured">
<security mode="Transport">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
Declaring transport security based endpoints is quite an easy task in WCF, but does require writing some binding configuration in the config file. WCF 4.5 helps reduce the amount of configuration by adding a new type of binding – basicHttpsBinding.
The basicHttpsBinding is similar to basicHttpBinding, only it has the following defaults:
- Security mode = Transport
- Client credential type = None
Setting up an endpoint with a basicHttps binding is quite simple:
<services>
<service name="WcfServiceLibrary1.Service1">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
<add baseAddress = "https://localhost:44310/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" contract="WcfServiceLibrary1.IService1"/>
<endpoint address="" binding="basicHttpsBinding" contract="WcfServiceLibrary1.IService1"/>
</service>
</services>
If you want to change the default client credential type for the secured endpoints, you will need to create a binding configuration for the secured endpoint:
<bindings>
<basicHttpsBinding>
<binding>
<security>
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpsBinding>
</bindings>
Note: Since this is a secured binding, the security mode can be either Transport or TransportWithMessageCredential only. TransportCredentialOnly is not supported for this type of binding.
Stay tuned for more posts about the new features of WCF 4.5. You can also follow me on Twitter (@IdoFlatow) to get updates as soon as new posts are published.
The RTM of .NET 4.5 is still to come, and I assume many of you are still adjusting to WCF 4. If you want to learn more about the new features of WCF 4, come to my session at Visual Studio Live! 2011 in Redmond (October 17-21).
Also, if you are an MCT and reside in the US, come hear my session about WCF 4 at the MCT 2011 North-America Summit that will be held in San-Francisco (October 19-21).
This is the sixth post in the WCF 4.5 series. In the previous post we’ve discussed new authentication features for services hosted in IIS, and this post is continuing the new IIS hosting features list - automatic HTTPS endpoints in IIS.
Previous posts:
1. What’s new in WCF 4.5? let’s start with WCF configuration
2. What’s new in WCF 4.5? a single WSDL file
3. What’s new in WCF 4.5? Configuration tooltips and intellisense in config files
4. What’s new in WCF 4.5? Configuration validations
5. What’s new in WCF 4.5? Multiple authentication support on a single endpoint in IIS
So what is the automatic HTTPS endpoint feature? WCF 4 introduced the default endpoint feature which enables the service host to automatically create default endpoints if no endpoint has been specified for the service. The default endpoints are created for each of the service host’s base addresses, according to a mapping between a base address scheme (HTTP, TCP…) and a matching binding. For example, if you have an HTTP base address, you will get an endpoint that uses the BasicHttp binding.
So what’s new in WCF 4.5? we now get another scheme mapping for HTTPS, so if your IIS has SSL enabled, and you don’t have any specific endpoints specified for the service, you will get both HTTP and HTTPS endpoints. The default binding for the HTTPS scheme is the same as for the HTTP scheme – BasicHttp binding.
How can you enable this feature?
1. Set up SSL in your IIS; there’s an excellent tutorial for this in the IIS.NET website.
2. Create the WCF service and host it in a web application.
3. Set the web application to be hosted in IIS.
4. Verify that the service doesn’t have any endpoint configuration set for it, so it will use default endpoints.
That’s it!
If you now browse to your service’s WSDL file, you will notice that you get two default endpoints – HTTP and HTTPS:

See anything strange? you are right! for some reason the two endpoints use different machine names in the address.
Since WCF 4, services hosted in IIS automatically use the useRequestHeadersForMetadataAddress behavior which constructs the endpoint host name according to the host name used in the WSDL GET request. This behavior is required especially for web farms where clients see a special host name and not the machine name itself, but as you can see, the automatic HTTPS endpoint does use the machine name for some reason, which can be a bit problematic when the IIS server is a part of a web farm.
If you have SSL set in IIS, but you’re not interested in having an HTTPS endpoint, you can remove it by removing the HTTPS scheme mapping as shown in the following XML configuration:
<system.serviceModel>
<protocolMapping>
<remove scheme="https"/>
</protocolMapping>
. . .
</system.serviceModel>
This new feature is very useful if you need HTTPS endpoints, since before this feature if we needed HTTPS endpoints, we couldn’t use the default endpoints and had to declare all endpoints manually, both HTTP and HTTPS. This is another step for making configuration files smaller.
Unfortunately, there is currently the bug of the host name, I hope it will be resolved by the time the new framework is released.
Stay tuned for more posts about the new features of WCF 4.5. You can also follow me on Twitter (@IdoFlatow) to get updates as soon as new posts are published.
The RTM of .NET 4.5 is still to come, and I assume many of you are still adjusting to WCF 4. If you want to learn more about the new features of WCF 4, come to my session at Visual Studio Live! 2011 in Redmond (October 17-21).
Also, if you are an MCT and reside in the US, come hear my session about WCF 4 at the MCT 2011 North-America Summit that will be held in San-Francisco (October 19-21).
October began yesterday with an email from Microsoft congratulating me for receiving Microsoft’s Most Valuable Professional (MVP) award. I’m a connected system developer MVP, which kind of describes my work – working with distributed systems, connecting clients and servers, building WCF services, ASP.NET applications, working with IIS servers, etc…
This is the first time I receive the MVP award, so I’m quite excited. Special thanks to the people who helped with my nomination – Guy Burstein and Meir Pinto from Microsoft Israel, to my managers at Sela Group – David Bassa and Ishai Ram, and of course to all of you that are reading my blog, that come to my sessions in conferences, to the hundreds of people I trained over the years, and to those whose nickname I only know that marked my answers as correct in forums. Congratulations also to my colleagues in Sela – Arik Poznanski for his new MVP in Visual C#, and to Gil Fink for his third year in a row of being a Data Platform MVP.
As I said before, this month bears many good news – next week I’m heading to Microsoft HQ in Redmond, where I’m going to attend an Azure Platform Metro course. Metro courses are special Microsoft courses that are constructed by DPE teams in Microsoft (developer and platform evangelists) and are intended to teach new technologies for eager developers. I’m going to participate in this course with several other trainers from all over the world, and learn the newest stuff in the Azure platform from Microsoft’s experts, so it’s going to be a great experience for me, and I’m very much looking forward to it.
October goes on with good stuff – the following week after the course I’m going to attend the Visual Studio Live! conference in Redmond (17-21 of October), this time not as a listener, but as a speaker.
I’m giving two sessions in the conference, about the new features of WCF 4, and about the new face of web development – ASP.NET MVC, jQuery, and Razor.
And for the finale of October – after my two sessions, I’m catching a flight to San-Francisco to attend the North-America 2011 MCT Summit (Microsoft Certified Trainers Summit), which is also during 19-21 of October. In the summit I will be presenting yet again the new features of WCF 4, but will also probably spend some time talking about teaching tips for the official WCF 4 course (10263A) that I co-authored last year for Microsoft.
If you are working in the area of Seattle or San-Francisco, and interested in WCF consulting or training, let me know as I have a few days off that I can dedicate to consultations and courses. I will be available in the Seattle area between 14-17 of October, and in the San-Francisco area between 21-22 of October. I also have a 9-hour connection in Newark on the 23rd, if you want a quick consultation 
October started great with my new MVP, and it’s going to end great with two weeks of learning and speaking in the US.