December 19, 2014
Hot Topics:

Client Application Services: Getting Started

  • March 19, 2008
  • By Vikas Goyal
  • Send Email »
  • More Articles »

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

  1. Create a new ASP.NET 3.5 Web Service Application using Visual Studio 2008. Name the application, say, 'ClientAppService'.


  2. Click here for a larger image.

    Figure 4: Create new ASP.NET Web Service Application

  3. 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.

  4. 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.

  5. Change the authentication mode to 'Forms' from the default value of 'Windows' because you will use 'Forms' authentication from your client code.
  6. <authentication mode="Forms" />
  7. Add a 'SampleProvider' class to the Web Service Application. It should inherit from the System.Web.Security.MembershipProvider class.
  8. public class SampleProvider : MembershipProvider
  9. 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.
  10. public override bool ValidateUser(string username,
       string password)
    {
       bool flag = false;
       if (username == "SampleUser" &&
           password == "SamplePassword")
          flag = true;
       return flag;
    }
    
  11. 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

  12. Build and start the Web Service Application.




Page 2 of 3



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Rocket Fuel