WebMethodAttribute Constructors

Definition

Initializes a new instance of the WebMethodAttribute class.

Overloads

WebMethodAttribute()

Initializes a new instance of the WebMethodAttribute class.

WebMethodAttribute(Boolean)

Initializes a new instance of the WebMethodAttribute class.

WebMethodAttribute(Boolean, TransactionOption)

Initializes a new instance of the WebMethodAttribute class.

WebMethodAttribute(Boolean, TransactionOption, Int32)

Initializes a new instance of the WebMethodAttribute class.

WebMethodAttribute(Boolean, TransactionOption, Int32, Boolean)

Initializes a new instance of the WebMethodAttribute class.

WebMethodAttribute()

Initializes a new instance of the WebMethodAttribute class.

C#
public WebMethodAttribute();

See also

Applies to

.NET Framework 4.8.1 y otras versiones
Producto Versiones
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

WebMethodAttribute(Boolean)

Initializes a new instance of the WebMethodAttribute class.

C#
public WebMethodAttribute(bool enableSession);

Parameters

enableSession
Boolean

Initializes whether session state is enabled for the XML Web service method.

Applies to

.NET Framework 4.8.1 y otras versiones
Producto Versiones
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

WebMethodAttribute(Boolean, TransactionOption)

Initializes a new instance of the WebMethodAttribute class.

C#
public WebMethodAttribute(bool enableSession, System.EnterpriseServices.TransactionOption transactionOption);

Parameters

enableSession
Boolean

Initializes whether session state is enabled for the XML Web service method.

transactionOption
TransactionOption

Initializes the transaction support of an XML Web service method.

Remarks

A web service call can only be the root of a transaction, due to the stateless nature of the HTTP protocol. This means that the following two settings are equivalent, with each call creating a new transaction:

[WebMethod(TransactionOption = TransactionOption.Required)]  
[WebMethod(TransactionOption = TransactionOption.RequiresNew)]  

It also means that all the following settings are equivalent; meaning no transaction support:

[WebMethod] // TransactionOption.Disabled is the default  
[WebMethod(TransactionOption = TransactionOption.Disabled)]  
[WebMethod(TransactionOption = Transaction.NotSupported)]  
[WebMethod(TransactionOption = Transaction.Supported)]  

Applies to

.NET Framework 4.8.1 y otras versiones
Producto Versiones
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

WebMethodAttribute(Boolean, TransactionOption, Int32)

Initializes a new instance of the WebMethodAttribute class.

C#
public WebMethodAttribute(bool enableSession, System.EnterpriseServices.TransactionOption transactionOption, int cacheDuration);

Parameters

enableSession
Boolean

Initializes whether session state is enabled for the XML Web service method.

transactionOption
TransactionOption

Initializes the transaction support of an XML Web service method.

cacheDuration
Int32

Initializes the number of seconds the response is cached.

Remarks

A web service call can only be the root of a transaction, due to the stateless nature of the HTTP protocol. This means that the following two settings are equivalent, with each call creating a new transaction:

[WebMethod(TransactionOption = TransactionOption.Required)]  
[WebMethod(TransactionOption = TransactionOption.RequiresNew)]  

It also means that all the following settings are equivalent; meaning no transaction support:

[WebMethod] // TransactionOption.Disabled is the default  
[WebMethod(TransactionOption = TransactionOption.Disabled)]  
[WebMethod(TransactionOption = Transaction.NotSupported)]  
[WebMethod(TransactionOption = Transaction.Supported)]  

Applies to

.NET Framework 4.8.1 y otras versiones
Producto Versiones
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

WebMethodAttribute(Boolean, TransactionOption, Int32, Boolean)

Initializes a new instance of the WebMethodAttribute class.

C#
public WebMethodAttribute(bool enableSession, System.EnterpriseServices.TransactionOption transactionOption, int cacheDuration, bool bufferResponse);

Parameters

enableSession
Boolean

Initializes whether session state is enabled for the XML Web service method.

transactionOption
TransactionOption

Initializes the transaction support of an XML Web service method.

cacheDuration
Int32

Initializes the number of seconds the response is cached.

bufferResponse
Boolean

Initializes whether the response for this request is buffered.

Remarks

A web service call can only be the root of a transaction, due to the stateless nature of the HTTP protocol. This means that the following two settings are equivalent, with each call creating a new transaction:

[WebMethod(TransactionOption = TransactionOption.Required)]  
[WebMethod(TransactionOption = TransactionOption.RequiresNew)]  

It also means that all the following settings are equivalent; meaning no transaction support:

[WebMethod] // TransactionOption.Disabled is the default  
[WebMethod(TransactionOption = TransactionOption.Disabled)]  
[WebMethod(TransactionOption = Transaction.NotSupported)]  
[WebMethod(TransactionOption = Transaction.Supported)]  

Applies to

.NET Framework 4.8.1 y otras versiones
Producto Versiones
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1