-
Book Overview & Buying
-
Table Of Contents
ASP.NET Web API Security Essentials
By :
Browsers don't pass credentials such as cookies and HTTP authentication schemes by default in cross-origin requests. To enable passing credentials in cross-origin requests from the client, the client has to set XMLHttpRequest.withCredentials to true as given in the following:
$.ajax({
type: 'get',
url: ' http://localhost:53858 /api/contacts,
xhrFields: {
withCredentials: true
}To allow credentials in cross-origin requests, the SupportsCredentials property should be set to true on the [EnableCors] attribute as given in the following code:
[EnableCors(origins: "http://chapter09client.com", headers: "*", methods: "*", SupportsCredentials = true)]
The HTTP response will also have the Access-Control-Allow-Credentials header, to indicate to the browser that the server is fine to accept credentials in cross-origin requests. Using Cookie or Authorization header, Web API authenticates the request. Once authenticated, the browser will...
Change the font size
Change margin width
Change background colour