Client Application Services: Getting Started, Page 2
Walkthrough
Now, you can create a sample ASP.NET application service and use it from a Windows Client using Client Application Services. The following sample uses Authentication request as an example.
Creating and Configuring an ASP.NET Application Service
- Create a new ASP.NET 3.5 Web Service Application using Visual Studio 2008. Name the application, say, 'ClientAppService'.
- Add the following XML code parallel to the <system.web> tag in the web service's web.config file.
<system.web.extensions> <scripting> <webServices> <authenticationService enabled="true" requireSSL = "false"/> </webServices> </scripting> </system.web.extensions>This code will expose the authentication service as a web service.
- Add the following XML code inside the <system.web> tag.
<membership defaultProvider="SampleProvider"> <providers> <add name="SampleProvider" type="ClientAppService.SampleProvider"/> </providers> </membership>This configures the Membership framework to use the custom 'SampleProvider' that will be developed in the next steps. The Membership provider is responsible for managing and validating the credentials.
- Change the authentication mode to 'Forms' from the default value of 'Windows' because you will use 'Forms' authentication from your client code.
- Add a 'SampleProvider' class to the Web Service Application. It should inherit from the System.Web.Security.MembershipProvider class.
- Implement the ValidateUser method of the class. For this walkthrough, credentials have been hard coded, but in a real application they should be placeed in some data store.
- Change the Project Properties to run the web service on a fixed port.
Project -> ClientAppService Properties -> Web -> Change the default setting of 'Auto-assign Port' to 'Specific Port' as shown in Figure 5.
Also, change the virtual path to '/ClientAppService'.

Click here for a larger image.Figure 5: Configure Web Service to run on a fixed port
- Build and start the Web Service Application.

Click here for a larger image.
Figure 4: Create new ASP.NET Web Service Application
<authentication mode="Forms" />
public class SampleProvider : MembershipProvider
public override bool ValidateUser(string username,
string password)
{
bool flag = false;
if (username == "SampleUser" &&
password == "SamplePassword")
flag = true;
return flag;
}
