WebService property record in asp.net

Source: Internet
Author: User
Tags http request

1 WebService Properties

[WebService (description= "ddddd"), namespace= "http://" "", Name= "name of WebService"]

2 Webmethod:web Service method (contains the following 6 properties)

Description: Comments on methods in the WebService service class

EnableSession: Identifies whether the current WebService starts the session, defaults to False, or (if False, cannot use the session object of ASP.net) ↓ uses the session's code;

///

Summary description of WebService1

///

[WebService (Namespace = "http://tempuri.org/")]

[WebServiceBinding (ConformsTo = wsiprofiles.basicprofile1_1)]

[System.ComponentModel.ToolboxItem (False)]

To allow the use of ASP.net AJAX to invoke this Web service from a script, uncomment the line.

[System.Web.Script.Services.ScriptService]

public class WebService1:System.Web.Services.WebService

{

[WebMethod (EnableSession = true, Description = "added operation")]

public string HelloWorld (string logname)

{

if (logname = "admin")

{

session["User"] = logname;

}

Else

{

Session.remove ("User");

}

if (session["User"] = = null)

{return ' not logged in ';}

Else

{return ' logged in ';}

}

}

MessageName: Used to implement overloading, because WebService cannot implement the overload of the parameter, so you need to use this property to flag the overload of the method

public int Add (int i)

[WebMethod (messagename= "ADD1")]

public int Add (int i,int j)

This means that when called, add is the first, ADD1 is the second method;

TransactionOption: (/-) understand for a half-day, just ready to verify, found in MSDN. net2.0 above version no longer supported, so) Indicates whether the current method is running under Transaction mode; (that is, when the method AAA is marked for transaction mode, if an exception occurs and is caught during the execution of the AAA method, then the AAA method is automatically rolled back to the state before the execution, and the transaction is committed if no exception occurs.) Unless the method displays the call SetAbort.

Where the transactionoption.disabled,notsupported identity does not run in transaction mode

Supported: Identifies the current method if there is a transaction (that is, the display indicates a transaction, such as the SQL Processing transaction) in the transaction mode, not in the normal mode of execution;

Required and Requirednew identify the current methods are executed in transaction mode;

CacheDuration: Indicates the cache time for the current method. default is not cached; (there may be a problem, the HTTP protocol supports the browser to set the HTTP header Cache-control property, and when the ASP.net application discovers the Cache-control=no-cache in the HTTP request, The cache set by the ASP.net program is ignored; PS: A little more understanding of the cache. )

Bufferresponse:msdn explains:

The BufferResponse property of the WebMethod attribute enables buffering of responses to XML Web services methods. When set to True (the default setting), ASP.net buffers the entire response before sending the response down to the client. Buffering is very effective, and it helps improve performance by minimizing communication between the worker process and the IIS process. When set to False, the ASP.net buffers the response with a 16KB chunk. Typically, this property is set to False only if you do not want to buffer the entire contents of the response once to memory. For example, you are writing back a collection that is outputting its items from the database as a stream. The default value is true unless otherwise specified. For more information, see WebMethodAttribute.BufferResponse property. Meaning: That is, when false, the ASP.net program will need to return to the browser's data 1.1 points, rather than all read into memory and then response; scenario: set to False when the data that needs to be returned is very large and does not want to consume too much memory. will return to browser without reading the 16kb content;

Note : For more wonderful tutorials, please pay attention to the Triple design Tutorials section,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.