15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

authentication <strong>and</strong> authorization ❘ 551<br />

Authentication services must be configured in the Web.config file. On the production system, it would be<br />

useful from a security st<strong>and</strong>point to configure SSL with the server hosting application services.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

code snippet AppServices/web.config<br />

Within the section, the membership <strong>and</strong> roleManager elements must be configured to<br />

reference the classes that implement the membership <strong>and</strong> role provider:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

For debugging, you can assign a port number <strong>and</strong> virtual path with the Web tab of project properties. The<br />

sample application uses the port 55555 <strong>and</strong> the virtual path /AppServices. If you use different values, you<br />

need to change the configuration of the client application accordingly.<br />

Now the application service can be used from a client application.<br />

Client application<br />

With the client application, WPF is used. Visual Studio has a project setting named Services that allows the use<br />

of client application services. Here, you can set Forms authentication <strong>and</strong> the location of the authentication<br />

<strong>and</strong> roles service to the address defined previously: http://localhost:55555/AppServices. All that’s done<br />

from this project configuration is to reference the assemblies System.Web <strong>and</strong> System.Web.Extensions,<br />

<strong>and</strong> change the application’s configuration file to configure membership <strong>and</strong> role providers that use the classes<br />

ClientAuthenticationMembershipProvider <strong>and</strong> ClientRoleProvider <strong>and</strong> the address of the Web<br />

service that is used by these providers.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!