/
ScriptMethodAttribute.xml
247 lines (204 loc) · 18.2 KB
/
ScriptMethodAttribute.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<Type Name="ScriptMethodAttribute" FullName="System.Web.Script.Services.ScriptMethodAttribute">
<TypeSignature Language="C#" Value="public sealed class ScriptMethodAttribute : Attribute" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit ScriptMethodAttribute extends System.Attribute" />
<TypeSignature Language="DocId" Value="T:System.Web.Script.Services.ScriptMethodAttribute" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class ScriptMethodAttribute
Inherits Attribute" />
<TypeSignature Language="F#" Value="type ScriptMethodAttribute = class
 inherit Attribute" />
<TypeSignature Language="C++ CLI" Value="public ref class ScriptMethodAttribute sealed : Attribute" />
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Attribute</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.AttributeUsage(System.AttributeTargets.Method)]</AttributeName>
<AttributeName Language="F#">[<System.AttributeUsage(System.AttributeTargets.Method)>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Specifies which HTTP verb is used to invoke a method, and the format of the response. This class cannot be inherited.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This attribute is used to specify information for methods that can be called from client script. The attribute lets you specify which HTTP verb (GET or POST) can be used to invoke a method. It also lets you specify whether the response is formatted by using either JavaScript Object Notation (JSON) or XML.
The <xref:System.Web.Script.Services.ScriptMethodAttribute> attribute is optional. (However, methods that can be called from client script must have the <xref:System.Web.Services.WebMethodAttribute?displayProperty=nameWithType> attribute applied.). If a method is not marked with <xref:System.Web.Script.Services.ScriptMethodAttribute>, the method will be called by using the HTTP POST command and the response will be serialized as JSON. You cannot override this setting from script.
<xref:System.Web.Script.Services.ScriptMethodAttribute> takes only named parameters. The following are the properties of the <xref:System.Web.Script.Services.ScriptMethodAttribute> class that can be used as named parameters:
- <xref:System.Web.Script.Services.ScriptMethodAttribute.UseHttpGet%2A>
Specifies whether the method will be invoked by using the HTTP GET command. The default is `false`.
> [!IMPORTANT]
> Setting the <xref:System.Web.Script.Services.ScriptMethodAttribute.UseHttpGet%2A> property to `true` might pose a security risk for your application if you are working with sensitive data or transactions. In GET requests, the message is encoded by the browser into the URL and is therefore an easier target for tampering. For both GET and POST requests, you should follow security guidelines to protect sensitive data.
- <xref:System.Web.Script.Services.ScriptMethodAttribute.ResponseFormat%2A>
Specifies whether the response will be serialized as JSON or as XML. The default is `Json`. The <xref:System.Web.Script.Services.ScriptMethodAttribute.ResponseFormat%2A> property is useful to specify XML as the return type when the method returns an <xref:System.Xml.XmlDocument> or an <xref:System.Xml.XmlElement> object.
- <xref:System.Web.Script.Services.ScriptMethodAttribute.XmlSerializeString%2A>
Specifies whether all return types, including string types, are serialized as XML. The value of the <xref:System.Web.Script.Services.ScriptMethodAttribute.XmlSerializeString%2A> property is ignored when the response is serialized as JSON.
For more information about how to use attributes, see [Attributes](/dotnet/standard/attributes/).
## Examples
The following example shows how to apply <xref:System.Web.Script.Services.ScriptMethodAttribute> to the `GetXmlDocument` and `EchoStringAndDate` methods to specify which HTTP verb to use and to specify the response format.
]]></format>
</remarks>
<altmember cref="T:System.Web.Services.WebMethodAttribute" />
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/bb515101(v=vs.100)">Using Web Services in ASP.NET AJAX</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/bb398998(v=vs.100)">Exposing Web Services to Client Script in ASP.NET AJAX</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/bb398995(v=vs.100)">Calling Web Services from Client Script in ASP.NET AJAX</related>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ScriptMethodAttribute ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Script.Services.ScriptMethodAttribute.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:
 ScriptMethodAttribute();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Web.Script.Services.ScriptMethodAttribute" /> class.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="ResponseFormat">
<MemberSignature Language="C#" Value="public System.Web.Script.Services.ResponseFormat ResponseFormat { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Web.Script.Services.ResponseFormat ResponseFormat" />
<MemberSignature Language="DocId" Value="P:System.Web.Script.Services.ScriptMethodAttribute.ResponseFormat" />
<MemberSignature Language="VB.NET" Value="Public Property ResponseFormat As ResponseFormat" />
<MemberSignature Language="F#" Value="member this.ResponseFormat : System.Web.Script.Services.ResponseFormat with get, set" Usage="System.Web.Script.Services.ScriptMethodAttribute.ResponseFormat" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Web::Script::Services::ResponseFormat ResponseFormat { System::Web::Script::Services::ResponseFormat get(); void set(System::Web::Script::Services::ResponseFormat value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.Script.Services.ResponseFormat</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the format of the method response.</summary>
<value>One of the <see cref="T:System.Web.Script.Services.ResponseFormat" /> values. The default is <see langword="Json" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Web.Script.Services.ScriptMethodAttribute.ResponseFormat%2A> property when you want to specify XML as the format for the return type. This is useful when the method returns an <xref:System.Xml.XmlDocument> or an <xref:System.Xml.XmlElement> object.
When the <xref:System.Web.Script.Services.ScriptMethodAttribute.ResponseFormat%2A> property is set to `Xml`, the public fields and properties of the return type that have the <xref:System.Web.Script.Serialization.ScriptIgnoreAttribute> attribute applied will not be ignored. This is because they will be serialized by using the <xref:System.Xml.Serialization.XmlSerializer> object instead of the <xref:System.Web.Script.Serialization.JavaScriptSerializer> object. You must apply the <xref:System.Xml.Serialization.XmlIgnoreAttribute> attribute to make <xref:System.Xml.Serialization.XmlSerializer> ignore, or skip, those public fields and properties of the return type.
## Examples
The following example shows how to apply the <xref:System.Web.Script.Services.ScriptMethodAttribute> attribute to a Web method with the <xref:System.Web.Script.Services.ScriptMethodAttribute.ResponseFormat%2A> 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 <xref:System.Xml.XmlDocument>. This code example is part of a larger example provided for the <xref:System.Web.Script.Services.ScriptMethodAttribute> class.
]]></format>
</remarks>
<altmember cref="T:System.Web.Script.Serialization.ScriptIgnoreAttribute" />
<altmember cref="T:System.Xml.Serialization.XmlIgnoreAttribute" />
</Docs>
</Member>
<Member MemberName="UseHttpGet">
<MemberSignature Language="C#" Value="public bool UseHttpGet { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool UseHttpGet" />
<MemberSignature Language="DocId" Value="P:System.Web.Script.Services.ScriptMethodAttribute.UseHttpGet" />
<MemberSignature Language="VB.NET" Value="Public Property UseHttpGet As Boolean" />
<MemberSignature Language="F#" Value="member this.UseHttpGet : bool with get, set" Usage="System.Web.Script.Services.ScriptMethodAttribute.UseHttpGet" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool UseHttpGet { bool get(); void set(bool value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a value that indicates whether to invoke the method by using HTTP GET.</summary>
<value>
<see langword="true" /> if the method is invoked by using the HTTP GET command; <see langword="false" /> if the method is invoked by using the HTTP POST command. The default is <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You cannot override this property from ECMAScript (JavaScript) on the client. If this property is set to `true`, invoking the method from script will always use HTTP GET.
When this property is set to `true`, the client proxy code uses HTTP GET to call the Web service. Each input parameter for the method appears as a query parameter in the URL that is used to invoke the Web method. The parameter value is obtained through JavaScript Object Notation (JSON) serialization and URL encoding of the parameter value.
The use of HTTP GET for invoking the Web service method follows the same guidelines for any other Web interaction. HTTP GET should be used only for operations where no sensitive data is exposed and when the server action does not have side effects.
> [!IMPORTANT]
> Setting the <xref:System.Web.Script.Services.ScriptMethodAttribute.UseHttpGet%2A> property to `true` might pose a security risk for your application if you are working with sensitive data or transactions. In GET requests, the message is encoded by the browser into the URL and is therefore an easier target for tampering.
## Examples
The following example shows how to apply <xref:System.Web.Script.Services.ScriptMethodAttribute> to a Web method with the <xref:System.Web.Script.Services.ScriptMethodAttribute.UseHttpGet%2A> property set to `true`. This code example is part of a larger example provided for the <xref:System.Web.Script.Services.ScriptMethodAttribute> class.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="XmlSerializeString">
<MemberSignature Language="C#" Value="public bool XmlSerializeString { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool XmlSerializeString" />
<MemberSignature Language="DocId" Value="P:System.Web.Script.Services.ScriptMethodAttribute.XmlSerializeString" />
<MemberSignature Language="VB.NET" Value="Public Property XmlSerializeString As Boolean" />
<MemberSignature Language="F#" Value="member this.XmlSerializeString : bool with get, set" Usage="System.Web.Script.Services.ScriptMethodAttribute.XmlSerializeString" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool XmlSerializeString { bool get(); void set(bool value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a value that indicates whether all return types are serialized as XML, which includes string types.</summary>
<value>
<see langword="true" /> if all return types are serialized as XML; otherwise, <see langword="false" />. The default is <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When this property is set to `false`, all return types are serialized as XML, except string, which is interpreted as XML markup. If the value is `false`, and if the return type is a string, and if the string does not contain XML markup that corresponds to a well-formed XML document, the succeeded callback function will be invoked but the resulting serialized string will be `null`.
The value of <xref:System.Web.Script.Services.ScriptMethodAttribute.XmlSerializeString%2A> is ignored when the <xref:System.Web.Script.Services.ScriptMethodAttribute.ResponseFormat%2A> property is set to `Json`.
## Examples
The following example shows how to apply <xref:System.Web.Script.Services.ScriptMethodAttribute> to a Web method with the <xref:System.Web.Script.Services.ScriptMethodAttribute.XmlSerializeString%2A> property set to `true`. This code example is part of a larger example provided for the <xref:System.Web.Script.Services.ScriptMethodAttribute> class.
]]></format>
</remarks>
<related type="Article" href="https://msdn.microsoft.com/library/78f88d7b-2d9c-40a5-a5c5-1277619077d0">Sys.Net.ClientServiceProxy Class</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/bb398995(v=vs.100)">Calling Web Services from Client Script in ASP.NET AJAX</related>
</Docs>
</Member>
</Members>
</Type>