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値の 1 つ。 既定値は Json です。

次の例では、ScriptMethodAttribute プロパティが ResponseFormat に設定された Web メソッドにXml属性を適用する方法を示します。 メソッドの戻り値は XML としてシリアル化され、 XmlDocument型のオブジェクトとして成功したコールバック関数に送信されます。 このコード例は、 ScriptMethodAttribute クラスに提供されるより大きな例の一部です。

注釈

戻り値の型の形式として XML を指定する場合は、 ResponseFormat プロパティを使用します。 これは、メソッドが XmlDocument または XmlElement オブジェクトを返す場合に便利です。

ResponseFormat プロパティが Xml に設定されている場合、ScriptIgnoreAttribute属性が適用されている戻り値の型のパブリック フィールドとプロパティは無視されません。 これは、XmlSerializer オブジェクトではなく、JavaScriptSerializer オブジェクトを使用してシリアル化されるためです。 戻り値の型のパブリック フィールドとプロパティXmlIgnoreAttribute無視またはスキップするには、XmlSerializer属性を適用する必要があります。

適用対象

こちらもご覧ください