TechBubbles Microsoft Technology BLOG

Creating an application using Silverlight Business Application Template

 

This post discusses how to create a WCF Data Service solution by using the Silverlight Business Application template. There are several features that you can work with this Business Application Template by writing little code. This post specifically discusses the authentication mechanisms forms and windows. By Default Silverlight Business Application allows the users to register and login with built in controls. image

This template also gives you navigation ability where you can easily add Silverlight pages for additional functionality. It also enables authentication, roles and profiles.

Creating a Visual Studio 2010 Silverlight Application

1. Select the Silverlight project type

image 

click ok. Notice that the following structure will be created where silverlight pages can be found in Silverlight client project views folder

image

2. Right click the Silverlight client project and select properties. Notice at the bottom of the project properties of the dialogue box RIA Services link exists between the client and server projects

image

3. Hit F5 and you will see the home page as below

image

4. Click on the login link then you will get the following login window

image

5. Click the registration link from above window then you will see the following window

image

By default Silverlight uses the Forms authentication. To use the windows authentication

Open the web.config file from Silverlight server project and change the authentication mode as shown below

   1: <authentication mode="Windows">

   2: </authentication>

Open the App.xaml.cs for the App.xaml file and change the code as shown in below

   1: /// <summary>

   2:         /// Creates a new <see cref="App"/> instance.

   3:         /// </summary>

   4:         public App()

   5:         {

   6:             InitializeComponent();

   7:  

8: // Create a WebContext and add it to the

ApplicationLifetimeObjects collection.

   9:             // This will then be available as WebContext.Current.

  10:             WebContext webContext = new WebContext();

  11:             //webContext.Authentication = new FormsAuthentication();

  12:             webContext.Authentication = new WindowsAuthentication();

  13:             this.ApplicationLifetimeObjects.Add(webContext);

  14:         }

Build and run the application, now you will notice login details with windows authentication.

image

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

2 Comments

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud