WebService attribute record in asp.net
1. webservice attributes
[Webservice (description = "ddddd"), namespace = "http: // '''", Name = "webservice Name"]
2 webmethod: web service method (including the following six attributes)
Description: Comment on methods in the webservice class
Enablesession: identifies whether the current webservice starts the session; the default value is false; (if false, the session object of asp.net cannot be used) the producer uses the session code;
////// Summary of WebService1 ///[WebService (Namespace = "http://tempuri.org/")] [WebServiceBinding (ConformsTo = WsiProfiles. basicProfile1_1)] [System. componentModel. toolboxItem (false)] // to allow ASP.. net ajax calls this Web service from a script. uncomment the following lines. // [System. web. script. services. scriptService] public class WebService1: System. web. services. webService {[WebMethod (EnableSession = true, Description = "")] public string HelloWorld (string logname) {if (logname = "admin ") {Session ["User"] = logname;} else {Session. remove ("User");} if (Session ["User"] = null) {return "not logged on";} else {return "logged on ";}}}
Messagename: Used to implement overloading. Because webservice cannot implement parameter overloading, this attribute must be used to mark method overloading.
public int Add(int i)
[webmethod(messagename="Add1")]public int Add(int i,int j)
In this way, "Add" indicates the first method and "Add1" indicates the second method;
TransactionOption :( (/□\) I understood it for half a day. I just prepared to verify it and found it in msdn. net2.0 and later versions are no longer supported. so...) indicates whether the current method runs in "transaction mode; (that is, when the method AAA is marked as running in transaction mode, if an exception occurs during the execution of the method AAA and is captured, the AAA method automatically rolls back to the status before execution. If no exception occurs, the transaction is committed. Unless this method shows that SetAbort is called ).
The TransactionOption. Disabled and NotSupported identifiers are not running in transaction mode.
Supported: identifies a transaction in the current method (indicating a transaction, such as an SQL transaction). If not, it is executed in normal mode;
Required and RequiredNew identify that the current method is executed in transaction mode;
CacheDuration: indicates the Cache Time of the current method. The default value is no cache. (There may be problems. HTTP supports setting the cache-control attribute of the http message header in the browser, when the asp.net application finds cache-control = no-cache in the http request, it will ignore the cache set by the asp.net program; ps: A little more understanding of the cache .)
BufferResponse: msdn explanation:
The BufferResponse Attribute (Property) of the WebMethod Attribute enables buffering of XML Web services method responses. When set to true (default), ASP. NET caches the entire response before sending the response to the client. The buffer is very effective. It helps improve performance by minimizing the communication between the auxiliary process and the IIS process. When set to false, ASP. NET caches responses in 16 KB blocks. Generally, this Property is set to false only when you do not want to buffer all the response content to the memory. For example, if you are writing a set, the set is outputting its items from the database as a stream. Unless otherwise specified, the default value is true. For more information, see webmethodattrise. BufferResponse attributes (Property ).
Meaning: When the value is false, the asp.net program will return the data to the browser at, instead of reading all the data to the memory and then Response. Application Scenario: when the data to be returned is very large, if you do not want to occupy too much memory, set it to false and return the data to the Browser if 16 KB is not read;