In order to allow a client application to access the ASP.NET
application services, there is a need to create an ASP.NET web application that
will function as a host to access the Membership, Role, and Profile services.
The client application will then reference that host
application to enable remote access to the services needed.
To start with, we will develop the ASP.NET application and
enable only the Membership and Role services for this article.
First of all, create a new ASP.NET website called
ASP.NETApplicationServices. The Membership service is enabled automatically and
it is configured by default to work with a database located in a SQL Server
2005 Express edition. To change this configuration and allow the Membership
service to interact with another database of your own, simply add the following
in the web.config configuration file.
<add connectionString="Data Source=.\SQL2005;Initial
Catalog=ClientApplicationServices;Integrated Security=True" name="LocalSqlServer"
The default connection string used is named LocalSqlServer,
so by removing it first and then adding it with different connection string
properties, allows the configured Membership provider to interact with the
One addition step is left which is to install the ASP.NET
2.0 Application Services database. This will not be explained in this article,
but this blog post shows in details how to do so: Install
Application Services Database on Microsoft SQL Server 2000/2005.
What we need is to enable Role management for this
application. This can be easily done by adding this configuration section to the
web.config configuration file.
<roleManager enabled="true" />
Now that the application is configured for Membership and
Role management services, a final step is required to give this website a fixed
port number since it is using the Visual Studio 2008 internal web server. This
is very important in case you are developing the host application as a website
which means every time you run this website, VS 2008 will generate a new port
number and assign it to the website and this breaks down the connection between
the client application and this host application. To remedy the situation, a
fixed port number is necessary so that every time VS 2008 runs this website, it
will use the same port number. This can be done by accessing the properties
page of the website and clicking on the Web tab. If you look under the Servers
section, you can find a radio button called Specific port. There you can set
the port number you want as shown in Figure 1.
Figure 1: ASP.NET website Web tab
The current configuration is enough to start creating the
client application to authenticate and authorize users.