Introduction

This article explaiins Form Authentication and how we can integrate it into the Web API.

What is Form Authentication

Form Authentication is used to send the references of the clients to the server in the HTML form. It is applicable for the Web API only that are calling from the Web Application. By which the client interact with the HTML form.

Advantages

The advantages of Form Authentication are:

Disadvantages

The disadvantages of Form Authentication are:

How Form Authentication works

server.jpg

Integrated windows Authentication

Integrated Windows Authentication provides the client for login with the references using the Kerberos and NTLM. It is appropriate for the internet environment. The user sends the References to the Authorization header.

Advantages of the integrated windows Authentication

Disadvantages of the integrated windows Authentication

For creating the application to be integrated with the Window Authentication. From the Visual Studio select the "MVC4 application". And select the "Internet Application" from the Template window of the MVC 4 wizard.

We set this code in the "Web.config" file.

  1. <system.web>
  2. <authentication mode="Windows" />
  3. </system.web>

At the client side, Windows Authentication can work on any browser but that browser supports the Negotiation authentication scheme, which includes the major browsers. There is the HttpClient class that supports the Windows Authentication for the client application.

  1. HttpClientHandler handler = new HttpClientHandler()
  2. {
  3. UseDefaultCredentials = true
  4. };
  5. HttpClient client = new HttpClient(handler);