This documentation is archived and is not being maintained.

WebServiceAttribute.Name Property

Gets or sets the name of the XML Web service.

Namespace:  System.Web.Services
Assembly:  System.Web.Services (in System.Web.Services.dll)

public string Name { get; set; }

Property Value

Type: System.String
The name for the XML Web service. Default value is the name of the class implementing the XML Web service.

The Service Description is generated when a user navigates to the URL for the XML Web service and supplies a query string of ?WSDL. Within the Service Description, the Name property identifies the local part of the XML qualified name for the XML Web service. The Name property is also used to display the name of the XML Web service on the Service help page. The Service help page is displayed when a prospective consumer navigates to the.asmx page for the XML Web service without specifying an XML Web service method name and its parameters.

An XML qualified name is used to disambiguate elements with the same name with an XML document. An XML qualified name consists of the following two parts separated by a colon: namespace or a prefix associated with a namespace and local part. The namespace consists of a URI reference and for the purposes of the Service Description, is the value of the Namespace property. In general, a prefix, which acts like an alias to an URI, is associated with the namespace, so that all subsequent XML qualified names using the namespace can use the shortened prefix. The local part is a string beginning with a letter or underscore containing no spaces. Therefore, the XML qualified name identifying a XML Web service in the Service Description is in the following format:

Namespace : Name

For more information on XML qualified names, see

The following example sets Name of the XML Web service to MyName.

<%@ WebService Language="C#" class= "ServerVariables"%>

 using System.Web.Services;

 [ WebService(Description="Server Variables",
 public class ServerVariables: WebService {
    [ WebMethod(Description="Returns the time as stored on the Server",
    public string Time() {
       return Context.Timestamp.TimeOfDay.ToString();

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0