RequirementsMode Property
Collapse the table of content
Expand the table of content

AspNetCompatibilityRequirementsAttribute.RequirementsMode Property

Gets or sets the level of ASP.NET compatibility required by the service.

Namespace: System.ServiceModel.Activation
Assembly: System.ServiceModel (in system.servicemodel.dll)

public AspNetCompatibilityRequirementsMode RequirementsMode { get; set; }
/** @property */
public AspNetCompatibilityRequirementsMode get_RequirementsMode ()

/** @property */
public void set_RequirementsMode (AspNetCompatibilityRequirementsMode value)

public function get RequirementsMode () : AspNetCompatibilityRequirementsMode

public function set RequirementsMode (value : AspNetCompatibilityRequirementsMode)

Not applicable.

Property Value

The AspNetCompatibilityRequirementsMode that indicates the services required degree of ASP.NET compatibility. The default value is NotAllowed, so that users must explicitly design a WCF service to be running in the compatibility mode.

Exception typeCondition


The value is not a valid one for the AspNetCompatibilityRequirementsModeenum.

Use the RequirementsMode property to set the hosting mode in code. This can also be done by setting an application-level configuration flag aspNetCompatibilityEnabled. For more information, see serviceHostingEnvironment.

At runtime, applications can detect whether ASP.NET compatibility mode is enabled by checking the value of the static property AspNetCompatibilityEnabled.

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class CalculatorService : ICalculatorSession
    double result
    {   // Store result in AspNet session.
            if (HttpContext.Current.Session["Result"] != null)
                return (double)HttpContext.Current.Session["Result"];
            return 0.0D;
            HttpContext.Current.Session["Result"] = value;

    public void Clear()

    public void AddTo(double n)
        result += n;

    public void SubtractFrom(double n)
        result -= n;

    public void MultiplyBy(double n)
        result *= n;

    public void DivideBy(double n)
        result /= n;

    public double Equals()
        return result;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

© 2016 Microsoft