Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.








ScriptServiceAttribute Class

Indicates that a Web service can be invoked from script. This class cannot be inherited.



[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class ScriptServiceAttribute : Attribute


<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Interface)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class ScriptServiceAttribute _
	Inherits Attribute


[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class ScriptServiceAttribute sealed : public Attribute


/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface) */
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal) */
public final class ScriptServiceAttribute extends Attribute


ScriptServiceAttributeNew()Initializes a new instance of the ScriptServiceAttribute class.
Equals(Object)Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Finalize()Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
GetHashCode()Returns the hash code for this instance. (Inherited from Attribute.)
GetType()Gets the Type of the current instance. (Inherited from Object.)
IsDefaultAttribute()When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Match(Object)When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
MemberwiseClone()Creates a shallow copy of the current Object. (Inherited from Object.)
ToString()Returns a String that represents the current Object. (Inherited from Object.)
TypeIdWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)


To invoke a Web service method from ECMAScript (JavaScript), you must apply the ScriptServiceAttribute attribute to the related Web service class. When you apply ScriptServiceAttribute to a Web service class definition that contains one or more methods with WebMethodAttribute applied, the proxy generation script creates a proxy object that corresponds to the Web service class.

For more information about using attributes, see Extending Metadata Using Attributes.


The following example demonstrates how to apply ScriptServiceAttribute to the Web service class definition so that its methods can be called from client script.


<%@ WebService Language="C#" Class="SimpleWebService" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;

[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class SimpleWebService : System.Web.Services.WebService 

    public string GetServerTime() 
        string serverTime =
            String.Format("The current time is {0}.", DateTime.Now);

        return serverTime;



<%@ WebService Language="VB" Class="SimpleWebService" %>

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Web.Script.Services

<WebService(Namespace:="")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ScriptService()> _
Public Class SimpleWebService
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function GetServerTime() As String
        Dim serverTime As String = _
         String.Format("The current time is {0}.", DateTime.Now)
        Return serverTime
    End Function

End Class


  • AspNetHostingPermission

    for operating in a hosted environment. Demand value: LinkDemand. Associated enumeration: Minimal.

Inheritance Hierarchy


Assembly: System.Web.Extensions (Module: System.Web.Extensions)