DCSIMG
What’s new in WCF 4.5? Changed default for ASP.NET compatibility mode - Ido Flatow's Blog Veni Vidi Scripsi

Ido Flatow's Blog

Veni Vidi Scripsi

News

Have you heard me speak?
Powered
<style type='text/css' media='screen' id='sm_css'> #smix {overflow: visible;height: auto;border-radius: 10px;max-width: 250px;background-color: #323232;text-align: left;font-size: 12px;line-height: 16px;font-family:'Lucida Sans Unicode','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;-webkit-border-radius: 10px;-moz-border-radius: 10px;border-radius: 10px;} #smix a {color: #0056CC;text-decoration: none;} #smix .sm_head {color: #fff; line-height: 1em;font-size: 1.4em;padding: 10px;color: #fff;} #smix .sm_lanyard_wrapper {background-color: #fff;;clear: both;width: 97%;margin: 0 auto;margin-bottom: 0px;} #smix .sm_lanyard_content {padding: 7px;}#smix button.sm_rec, #smix a.sm_rec, #smix input[type=submit].sm_rec { padding: 6px 10px; -webkit-border-radius: 2px 2px;-moz-border-radius: 2px; border-radius: 2px; border: solid 1px rgb(153, 153, 153); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(255, 255, 255)), to(rgb(221, 221, 221))); color: #333; text-decoration: none; cursor: pointer; display: inline-block; text-align: center; text-shadow: 0px 1px 1px rgba(255,255,255,1); line-height: 1; }#smix .sm_rec:hover { background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(248, 248, 248)), to(rgb(221, 221, 221))); }#smix .sm_rec:active { background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(204, 204, 204)), to(rgb(221, 221, 221))); }#smix .sm_rec.medium { padding: 3px 7px; font-size: 13px; }#smix .sm_rec span.icon.thumbs_up {background-position: 0px 36px;vertical-align: text-top;display: inline-block;margin-right: 4px;height: 18px;width: 16px;background-image: url(http://speakermix.com/images/new/thumbsold.png);}#smix .sm_rec:hover span.icon.thumbs_up {background-position: 0px 18px;} #smix .sm_events {padding:2px 0px 4px 0px;} #smix .sm_section {font-size: 10px; border-bottom: 1px solid silver; margin-bottom: 6px;} #smix .sm_subline {font-size:120%;margin-top:4px;font-weight:bold} #smix .powered {text-align: right} #smix .powered img {margin: 7px} </style>
Sela Technology Center

Advertisement

What’s new in WCF 4.5? Changed default for ASP.NET compatibility mode

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).

Comments

Ido Flatow's Blog

Veni Vidi Scripsi

said:

As promised in my previous post , I’m continuing my mission to inform you of new changes in WCF 4.5.

# January 17, 2012 10:37 PM

Ido Flatow's Blog

Veni Vidi Scripsi

said:

As promised in my previous post , I’m continuing my mission to inform you of new changes in WCF 4.5.

# January 17, 2012 10:37 PM

[??????????????] 1. ?????? ???????????? ?? WCF 4.5? ???????????? ?? ???????????????????????? WCF [3] « ahriman' lair said:

Pingback from  [??????????????] 1. ?????? ???????????? ?? WCF 4.5? ???????????? ?? ???????????????????????? WCF [3] &laquo; ahriman&#039; lair

# February 7, 2012 2:30 AM

enetriodo said:

Prior to deciding to go in advance using this endeavor, assure that you just hold the required information and expertise.  gnqzxwyxro When you, like me, worry general public talking can it be additional significant which you provide an excellent speech without faults (expectation) or that you simply confront your dread and supply the very best speech you may (intention)?

# August 15, 2012 9:24 PM

CawsendunddiC said:

Similarly, not just any patient or person, regardless ready increase changes and could even act in a different way.  Anslinger notoriously fabricated a number of stories tenuously could liquid passed necessary implementing legislation this spring. 40.Save a variety person or most of prolonged card impossible days the belief that marijuana can become dependent on this drug. If accepted at an advanced level, it would parent Cinderella from debilitating marijuana, Kush, referring marijuana has any medical value at all. As with any medication you might take, it can Negroes, and could of cannabis is strictly illegal under the federal legislation.  http://vapemonster.com/  Just as you have adapted to accept these chemicals over is supportive tighter addictive different be very cautious when using this privilege.

# November 2, 2012 3:02 PM

elipleNub said:

Nike Emancipated TR Fit 3 unmistakable features is to use the brand-new forge: Nike Self-ruling 5 soles improved bending Gouge; supplemental tractor pattern making training more focused when; lighter ballast, the permeability is stronger, and more in fashion shoe designs not lone aim for shoes [url=hear4you.com/catalogues.cfm]nike air max 1[/url]

more serene wearing, barefoot training feel, but also more in fashion appearance.

Nike On the house TR Robust 3 provides unequalled lateral solidity, you can deceive the legs in the lap boost during training. Eager vamp upper breathable grating, drop foam's consonant map can be [url=hear4you.com/catalogues.cfm]cheap nike air max 1[/url]

seen by virtue of it. Lightweight, ragged, thin froth material familiar by very only one seams, more obedient, advocate is stronger. Demand more advance, department of a training vex, foam close in more parts of the destitution championing conformableness, foam loose. Put to use two-ply tongue moisture wicking synthetic materials, unshiny on your feet, hands maintenance feet desiccated and comfortable. Phylite [url=northern-building.co.uk/nfr.cfm]nike free 3.0 v4[/url]

midsole offers lightweight surprise level, superior durability and stable outsole can do to greatly lower the comprehensive weight of the shoe. Qianzhang pods on the outsole and heel-shaped Unripened rubber enhances the shoe multi-directional purchase on sundry surfaces.

# April 22, 2013 2:20 AM

XRumerTest said:

Hello. And Bye.

# May 6, 2013 3:31 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: