In my webAPI i'm using the [Authorize] control.
When I call my webAPI to populate a grid or a dropdown with this code
.DataSource(source=>source.Custom()
.Transport(transport=>transport.Read(read=>
{
read.Url($"{WebApiUrl}")
.DataType("json").Data("forgeryToken");
})
)
.PageSize(12)
only in localhost it returns this error <Failed to load resource: the server responded with a status of 401 (Unauthorized)> .
Instead if I use an ajax call in javascript it works
$.ajax({
url: `${WebApiUrl}`,
method: 'get',
crossDomain: true,
cache: false,
xhrFields: {
withCredentials: true,
},
success: function (data) {
options.success(data)
}
})
I've searched in google but i didn't find anything that can help me. Do I have to pass the credentials somehow?
Thank you