ScriptMethodAttribute.ResponseFormat 屬性

定義

取得或設定方法回應的格式。

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

屬性值

ResponseFormat

其中一個 ResponseFormat 值。 預設為 Json

範例

下列範例示範如何將屬性 ScriptMethodAttribute (property)設定為的 Web 方法 ResponseFormat Xml 。 方法的傳回值將會序列化為 XML,並傳送至成功的回呼函式作為型別的物件 XmlDocument 。 這個程式碼範例是針對類別提供之較大範例的一部分 ScriptMethodAttribute

備註

ResponseFormat當您想要將 XML 指定為傳回類型的格式時,請使用屬性。 當方法傳回或物件時,這會很有用 XmlDocument XmlElement

ResponseFormat 屬性設定為時 XmlScriptIgnoreAttribute 將不會忽略已套用屬性之傳回型別的公用欄位和屬性。 這是因為它們會使用 XmlSerializer 物件而非物件來進行序列化 JavaScriptSerializer 。 您必須套用 XmlIgnoreAttribute 屬性,以 XmlSerializer 忽略或略過傳回型別的公用欄位和屬性。

適用於

另請參閱