in a WebAPI mvc project How can I read the logged user in my APIController?
send the credentials with the request from the client side by adding withCredentioals:true
$.ajax({ url: ajaxURL,
crossDomain: true,
xhrFields: {
withCredentials: true
},
success: function (data) { alert(data); },
});
From your WebAPI server Add the following decoration to allow the cross origin request and to allow the credentioals: [EnableCors(origins: "http://YourClientServer:PORT", headers: "*", methods: "*", SupportsCredentials = true)]
SupportsCredentials will add the header access-control-allow-credentials = true to your response