AJAX Extensions 1.0 shipped with built-in client-side Application
Services. This means that with AJAX 1.0 Extensions you can authenticate users,
process user roles, and load and save user’s profile without the need to
postback to the server.
To be able to allow the client-side code to interact with
the Application Services, you need to configure them in the Web.config
configuration file as follows.
Listing 2
<system.web.extensions>
<scripting>
<webServices>
<authenticationService enabled="true" requireSSL = "false"/>
<profileService enabled="true"
readAccessProperties="UserName"
writeAccessP-roperties="UserName" />
<roleService enabled="true"/>
</webServices>
</scripting>
</system.web.extensions>
The above enables the Authentication, Profile, and Role
services so that the AJAX engine creates client-side proxies so that the
client-side JavaScript can interact with the Application Services on the server
in an asynchronous way.
Every client-side proxy for the above services is configured
with HttpHandler to know where to post the asynchronous request on the server.
For instance, the Authentication Service is configured with the
Authentication_JSON_AppService.axd HttpHandler. When a request accesses the
aforementioned HttpHandler, the handler checks what Membership provider is
configured in the web application on the server and accordingly it redirects
the request to that configured provider. For instance, a call to Login method
on the HttpHandler would be redirected to the Login method implementation of the
configured Membership provider in the Web.config configuration file of the
application
You can also configure the application services to interact
with your Web services instead of using the built-in HttpHandlers. This can be
very easy and a matter of setting the path of the Web services that will do the
authentication operations to the Path property of the AuthenticationService
class located inside the ScriptManager instance. Here is an example of how to
do so.
Listing 3
<asp:ScriptManager ID="ScriptManager1" runat="server">
<AuthenticationService Path="~/AuthenticationService.asmx" />
</asp:ScriptManager>
After all, whether the client-side proxy is accessing a Web
service, which is nothing but a compiled class on the server, or the
HttpHandler which instantiates an instance of the configure MembershipProvider,
the same functionality is present.