This tutorial will show you how to use ASP.NET 3.5 Application Services. These services can be accessed over the Web to enable client applications to use user authentication, role, and profile information.
In this tutorial we will show you how to configure and use ASP.NET 3.5 application services. To start we will configure an ASP.NET Web site to expose these application services. You will create a Web site that will use roles, log-ins and creating users and services. For this you will need to use Visual Studio 2008 and SQL Server or SQL Server Express Edition installed on your pc. Here are a few snapshots of what the Web site will look like:
First we need to create the application services Web site. Open Visual Studio 2008 and from the file menu, click > New Web Site > ASP.NET Web Site > name it WindowsAppServices. Then click OK. Notice how Visual Studio creates a new Web site and opens the default.aspx page. From here navigate to the properties window, click in the Solution Explorer > the name of the website > then back to the properties window and set the dynamic ports to False.
**Make sure that you click in the Solution Explorer to the name of the Web site then to the Property Pages window. You cannot access the Web Site Properties window from the Property Pages window. Next set the Port number to 8080, or use a different port number, just make sure that you change it when needed throughout this tutorial.
Need help with Windows Dedicated Hosting? Try Server Intellect I'm a happy customer!
Now we can write the code that will create users and roles for this Web site. The first time that the Web site is accessed, the database is automatically created, however we still need to add two roles (Employees and Customers) to the database.
In order to create users and role information we need to add a global.asax file to the Web site. So first we need to add the Global.asax file. We can do this by locating the Solution Explorer > Right-click on name of Web site > Add New Item > Global Application Class > click Add. Then replace the following code in the Application_Start method:
|void Application_Start(object sender, EventArgs e)
Again, the first time this Web site is accessed, the code creates soemthing similar to a .mdf (access) database in the App_Data folder and adds the roles Employees and Customers to it. This database is then used to store profile, roles, and credential information. Now open the default.aspx page and replace the markup with this markup: