ScriptMethodAttribute.ResponseFormat 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置方法响应的格式。
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 值。 默认值为 Json。
示例
以下示例演示如何将ScriptMethodAttribute属性应用于属性设置为ResponseFormat的 Xml Web 方法。 方法的返回值将序列化为 XML,并将其作为类型的 XmlDocument对象发送到成功的回调函数。 该代码示例是 ScriptMethodAttribute 类中的一个较大示例的一部分。
注解
ResponseFormat如果要将 XML 指定为返回类型的格式,请使用该属性。 此方法返回对象 XmlDocument 或 XmlElement 对象时非常有用。
当属性 ResponseFormat 设置为 Xml时,将不忽略应用属性的返回类型的 ScriptIgnoreAttribute 公共字段和属性。 这是因为将使用对象而不是XmlSerializer对象对其进行序列化JavaScriptSerializer。 必须应用该 XmlIgnoreAttribute 属性才能忽略 XmlSerializer 或跳过返回类型的这些公共字段和属性。