AspNetCompatibilityRequirementsAttribute.RequirementsMode Propiedad

Definición

Obtiene o establece el nivel de compatibilidad ASP.NETASP.NET requerido por el servicio.Gets or sets the level of ASP.NETASP.NET compatibility required by the service.

public:
 property System::ServiceModel::Activation::AspNetCompatibilityRequirementsMode RequirementsMode { System::ServiceModel::Activation::AspNetCompatibilityRequirementsMode get(); void set(System::ServiceModel::Activation::AspNetCompatibilityRequirementsMode value); };
public System.ServiceModel.Activation.AspNetCompatibilityRequirementsMode RequirementsMode { get; set; }
member this.RequirementsMode : System.ServiceModel.Activation.AspNetCompatibilityRequirementsMode with get, set
Public Property RequirementsMode As AspNetCompatibilityRequirementsMode

Valor de propiedad

AspNetCompatibilityRequirementsMode que indica el grado requerido de compatibilidad ASP.NETASP.NET de los servicios.The AspNetCompatibilityRequirementsMode that indicates the services required degree of ASP.NETASP.NET compatibility. El valor predeterminado es Allowed.The default value is Allowed.

Excepciones

El valor no es válido para AspNetCompatibilityRequirementsModeenum.The value is not a valid one for the AspNetCompatibilityRequirementsModeenum.

Ejemplos

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class CalculatorService : ICalculatorSession
{
    double result
    {   // Store result in AspNet session.
        get
        {
            if (HttpContext.Current.Session["Result"] != null)
                return (double)HttpContext.Current.Session["Result"];
            return 0.0D;
        }
        set
        {
            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;
    }
}
    <AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Required)> _
    Public Class CalculatorService
        Implements ICalculatorSession

        Property Result() As Double
            ' Store result in AspNet Session.
            Get
                If (HttpContext.Current.Session("Result") Is Nothing) Then
                    Return 0D
                End If
                Return HttpContext.Current.Session("Result")
            End Get
            Set(ByVal value As Double)
                HttpContext.Current.Session("Result") = value
            End Set
        End Property

        Public Sub Clear() _
 Implements ICalculatorSession.Clear
            Result = 0D
        End Sub

        Public Sub AddTo(ByVal n As Double) _
Implements ICalculatorSession.AddTo
            Result += n
        End Sub

        Public Sub SubtractFrom(ByVal n As Double) _
Implements ICalculatorSession.SubtractFrom

            Result -= n
        End Sub

        Public Sub MultiplyBy(ByVal n As Double) _
Implements ICalculatorSession.MultiplyBy

            Result *= n
        End Sub

        Public Sub DivideBy(ByVal n As Double) _
Implements ICalculatorSession.DivideBy

            Result /= n
        End Sub

        Public Function Equal() As Double _
Implements ICalculatorSession.Equal

            Return Result
        End Function
    End Class

Comentarios

Utilice la propiedad RequirementsMode para establecer el modo de hospedaje en el código.Use the RequirementsMode property to set the hosting mode in code. Esto también se puede hacer estableciendo una marca de configuración en el nivel de la aplicación aspNetCompatibilityEnabled.This can also be done by setting an application-level configuration flag aspNetCompatibilityEnabled. Para obtener más información, <vea>serviceHostingEnvironment.For more information, see <serviceHostingEnvironment>.

En el tiempo de ejecución, las aplicaciones pueden detectar si el modo de compatibilidad ASP.NETASP.NET está habilitado comprobando el valor de la propiedad AspNetCompatibilityEnabled estática.At runtime, applications can detect whether ASP.NETASP.NET compatibility mode is enabled by checking the value of the static property AspNetCompatibilityEnabled.

Se aplica a