Client Application Services: Getting Started
Creating the Windows Client
- Create the .NET 3.5 client Windows Forms application using Visual Studio 2008 and name it, say, 'ClientApp'.
- Change the Project Properties so that the application uses Client Application Services to connect to the ASP.NET Application Service created in earlier steps.
Project -> ClientApp Properties -> Services:
- Select 'Enable client application services'
- Select 'Use Forms authentication'
- Specify the URL based on port given earlier.
- Add controls to the startup form to accept login credentials and also a button to submit the form, as shown in Figure 8.
- In the 'Login' button click event, add the following code to call the Membership API and pass the entered credentials.
- Build and execute the application. Make sure that Web Service created earlier is running.
- To test, provide wrong credentials. You will get the output shown in Figure 9.
- Provide correct credentials this time, and the output will be as in Figure 10:

Click here for a larger image.
Figure 6: Creating a new Windows Forms Application

Click here for a larger image.
Figure 7: Enable Client Application Service

Figure 8: Client Login Form
if (!Membership.ValidateUser(textUserName.Text,
textPassword.Text))
{
MessageBox.Show("Incorrect Username or Password",
"Pls try again",
MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
else
{
MessageBox.Show("Login Successful","Welcome",
MessageBoxButtons.OK, MessageBoxIcon.Information);
Application.Exit();
}

Figure 9: Output on wrong credentials

Figure 10: Output on correct credentials
Conclusion
Client Application Services simplifies the access to ASP.NET Application Services and thus helps in managing the user information, authentication, and authorization at a common place for both web and Windows Applications.
Other important things that can be tried out using Client Application Services are:
- Accessing directly from Client Application Services classes
- Configuring offline support
- Implementing logout functionality
About the Author
Vikas Goyal is a Microsoft MVP Solutions Architect with several years of industry experience. He is mainly involved in designing products/solutions for Financial Industry. He can be contacted via his web site, http://www.VikasGoyal.net; or his blog, http://dotnetwithme.blogspot.com.



Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.