編輯

共用方式為


ScriptMethodAttribute.ResponseFormat Property

Definition

Gets or sets the format of the method response.

public:
 property System::Web::Script::Services::ResponseFormat ResponseFormat { System::Web::Script::Services::ResponseFormat get(); void set(System::Web::Script::Services::ResponseFormat value); };
public System.Web.Script.Services.ResponseFormat ResponseFormat { get; set; }
member this.ResponseFormat : System.Web.Script.Services.ResponseFormat with get, set
Public Property ResponseFormat As ResponseFormat

Property Value

One of the ResponseFormat values. The default is Json.

Examples

The following example shows how to apply the ScriptMethodAttribute attribute to a Web method with the ResponseFormat property set to Xml. The return value of the method will be serialized as XML and sent to the succeeded callback function as an object of type XmlDocument. This code example is part of a larger example provided for the ScriptMethodAttribute class.

Remarks

Use the ResponseFormat property when you want to specify XML as the format for the return type. This is useful when the method returns an XmlDocument or an XmlElement object.

When the ResponseFormat property is set to Xml, the public fields and properties of the return type that have the ScriptIgnoreAttribute attribute applied will not be ignored. This is because they will be serialized by using the XmlSerializer object instead of the JavaScriptSerializer object. You must apply the XmlIgnoreAttribute attribute to make XmlSerializer ignore, or skip, those public fields and properties of the return type.

Applies to

See also