This documentation is archived and is not being maintained.

WebScriptEnablingBehavior Class

Provides support for the behavior that enables endpoints to receive HTTP requests from a browser-based ASP.NET AJAX client. This class cannot be inherited.


Namespace:  System.ServiceModel.Description
Assembly:  System.ServiceModel.Web (in System.ServiceModel.Web.dll)

Public NotInheritable Class WebScriptEnablingBehavior _
	Inherits WebHttpBehavior

The WebScriptEnablingBehavior type exposes the following members.

Public methodWebScriptEnablingBehaviorInitializes a new instance of the WebScriptEnablingBehavior class.

Public propertyAutomaticFormatSelectionEnabledGets or sets a value that determines if automatic format selection is enabled. (Overrides WebHttpBehavior.AutomaticFormatSelectionEnabled.)
Public propertyDefaultBodyStyleGets or sets the default message body style. (Overrides WebHttpBehavior.DefaultBodyStyle.)
Public propertyDefaultOutgoingRequestFormatGets or sets the default outgoing request message format. (Overrides WebHttpBehavior.DefaultOutgoingRequestFormat.)
Public propertyDefaultOutgoingResponseFormatGets and sets the default outgoing response message format. (Overrides WebHttpBehavior.DefaultOutgoingResponseFormat.)
Public propertyFaultExceptionEnabledGets or sets the flag that specifies whether a FaultException is generated when an internal server error (HTTP status code: 500) occurs. (Overrides WebHttpBehavior.FaultExceptionEnabled.)
Public propertyHelpEnabledGets or sets a value that determines if the REST Help page is enabled. (Overrides WebHttpBehavior.HelpEnabled.)
Protected propertyJavascriptCallbackParameterNameGets or sets the JavaScript callback parameter name. (Inherited from WebHttpBehavior.)

Public methodAddBindingParametersImplements the AddBindingParameters(ServiceEndpoint, BindingParameterCollection) method to pass data at runtime to bindings to support custom behavior. (Inherited from WebHttpBehavior.)
Protected methodAddClientErrorInspectorAdds a client error inspector to the specified service endpoint. (Inherited from WebHttpBehavior.)
Protected methodAddServerErrorHandlersOverride this method to change the way errors that occur on the service are handled. (Inherited from WebHttpBehavior.)
Public methodApplyClientBehaviorApplies the behavior to the client across an endpoint. (Overrides WebHttpBehavior.ApplyClientBehavior(ServiceEndpoint, ClientRuntime).)
Public methodApplyDispatchBehaviorApplies the behavior to the service endpoint. (Overrides WebHttpBehavior.ApplyDispatchBehavior(ServiceEndpoint, EndpointDispatcher).)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Protected methodGetOperationSelectorCreates a new WebHttpDispatchOperationSelector object. (Inherited from WebHttpBehavior.)
Protected methodGetQueryStringConverterGets the query string converter. (Inherited from WebHttpBehavior.)
Protected methodGetReplyClientFormatterGets the reply formatter on the client for the specified endpoint and service operation. (Inherited from WebHttpBehavior.)
Protected methodGetReplyDispatchFormatterGets the reply formatter on the service for the specified endpoint and service operation. (Inherited from WebHttpBehavior.)
Protected methodGetRequestClientFormatterGets the request formatter on the client for the specified service operation and endpoint. (Inherited from WebHttpBehavior.)
Protected methodGetRequestDispatchFormatterGets the request formatter on the service for the given service operation and service endpoint. (Inherited from WebHttpBehavior.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodValidateConfirms that the endpoint meets the requirements that allow it to function as an ASP.NET AJAX endpoint. (Overrides WebHttpBehavior.Validate(ServiceEndpoint).)
Protected methodValidateBindingEnsures the binding is valid for use with the WCF Web Programming Model. (Inherited from WebHttpBehavior.)

When applied to an endpoint, the WebScriptEnablingBehavior behavior enables and ASP.NET AJAX integration, except for the support required for JavaScript Object Notation (JSON) encoding. Various types of encoding, including JSON, are enabled by the WebMessageEncodingElement or by an appropriately configured WebHttpBinding. The WebScriptEnablingBehavior behavior implements the IEndpointBehavior and inherits from WebHttpBehavior, which enables the more general Web programming model for services exposing non-SOAP endpoints.

Specifically, the WebScriptEnablingBehavior:

  • Enables the HTTP programming model, including dispatch to operations based on a URL suffix, support for HTTP verb selection (POST or GET) and HTTP cache duration control. For more information about the HTTP programming model, see WCF Web Programming Model Overview. Note that the default HTTP verb is POST when using this behavior.

  • Enables the correct formatter for each operation's request and response messages - for example, support for URL parameters.

  • Enables the JavaScript Proxy endpoint.

To call a service from an ASP.NET AJAX client, the service must be configured with the WebHttpBinding binding and the WebScriptEnablingBehavior must be added to the endpoint behavior collection. This can be done either in configuration by adding the WebScriptEnablingElement or without using configuration by activating the AJAX endpoint with the WebScriptServiceHostFactory instead of the default factory in the @ServiceHost directive in the .svc file.

For more information about different ways to enable a service to respond to ASP.NET AJAX clients, see Creating WCF Services for ASP.NET AJAX.

.NET Framework

Supported in: 4, 3.5

.NET Framework Client Profile

Supported in: 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.