Is there a way to initiate an AJAX post request with the Authorization header for the initial request using Windows Authentication?

I'm working on a web application that has a video page and a Web API for logging purposes. The events are triggered using an ajax post request:

function logAction(actionToLog) {
    $.ajax({
        type: 'POST',
        url: "/api/v/" + currentVideoName + "/" + currentUser + "/" + vid.currentTime + "/" + actionToLog + "/" + currentBrowserType + "/",
        cache: false,
        contentType: 'application/json; charset=utf-8'
    });

Upon inspecting the calls in Fiddler, I noticed that each call is being duplicated:

First Request (Unauthorized 401) without authorization token:

POST http://HOSTNAME/api/v/ValuePropVideo1/tfrick/0/started/Chrome/ HTTP/1.1
Host: HOSTNAME
Connection: keep-alive
Content-Length: 0
Cache-Control: max-age=0
Accept: */*
Origin: http://HOSTNAME
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36
Content-Type: application/json; charset=utf-8
Referer: http://HOSTNAME/v/ValuePropVideo1
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8

Second Request (valid) with authorization token:

Authorization: Negotiate YIII+QYGKwYBBQUCo...

Logging page load and video completion events works fine as the browser remains open. However, when triggering the call for user closing the browser, only the first request is sent resulting in a 401 error.

My query is: How can I ensure these ajax calls are made using the Windows credentials?

Answer №1

After facing a challenging problem for an extended period, I made the decision to delve into the IIS configuration and eliminate the "Negotiate" provider from the advanced settings of "Windows Authentication" in the "Authorization" section, opting to keep only NTML. This adjustment successfully resolved my issue.

site->Authentication->Windows Authentication->Providers

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Failure to successfully transmit data from Ajax to PHP script

When I click on a button in my HTML page, I am trying to retrieve information from my PHP code, but it is not connecting properly. The front page displayed in index.php is as follows: <!DOCTYPE html> <html> <head> <link rel="styleshe ...

Can anyone recommend a speedy sorting algorithm for an extensive list of objects in JavaScript?

Struggling to organize a large array of 2000 elements in ReactJS using JavaScript. The array includes: data = [ { index: 0, id: "404449", product_name: "ette", brand_name: "Dyrberg/Kern", base_pri ...

What is the best way to refresh updated information by clicking a button?

I am looking to update a user's data by entering new values in the textbox, such as their first name, and have these changes reflected in their profile. I attempted to implement Ajax for this task, but I am unsure about what the correct URL should be. ...

Can someone help me figure out where I'm going wrong with the JS ternary conditional operator

Looking to improve my JavaScript logic skills as a beginner. Appreciate any tips or feedback on the function and not just this specific question. I'm curious why the code outputs --> [3,5] function divisors(integer) { let divisors = [] for (le ...

Uploading files with Jquery and Ajax

I'm trying to use JQuery to post a file upload to the current page, then proceed with the file upload and insert it successfully. However, I'm encountering an issue where the code doesn't seem to work as intended. Specifically, JQuery is una ...

Scrolling vertically without the appearance of a scrollbar

I've searched all over the internet for a solution to my problem, but nothing seems to work for me. I want to keep vertical scrolling ability while hiding the scrollbar from view in the y direction all the time. The challenge is to make my #content-m ...

How can I use jQuery mobile to request page content by simply clicking on a div?

I'm attempting to retrieve data from a callback page (php) and inject it into an html div using jQuery mobile when a user clicks on another div. Here's what I have: $.('#home-button').bind('vclick', function( e ) { $.get ...

Utilize Javascript ES6 to Sort Through Data in a Table

I require assistance with my project using Material UI and React. There are two key implementations that I need: I am looking to create a filtering system for all rows in each column as shown in the attached image. Additionally, I need a button that can a ...

Using Sequelize to update all values in a JSON file through an Express router.put operation

I've been working on a feature in my Express router that updates data in a MySQL schema for 'members' of clubs. The members table has various columns like member_id, forename, surname, address, etc. I've successfully created an Express ...

What could be causing TypeScript to throw errors when attempting to utilize refs in React?

Currently, I am utilizing the ref to implement animations on scroll. const foo = () => { if (!ref.current) return; const rect = ref.current.getBoundingClientRect(); setAnimClass( rect.top >= 0 && rect.bottom <= window.i ...

Tips for creating a seamless merge from background color to a pristine white hue

Seeking a seamless transition from the background color to white at the top and bottom of the box, similar to the example screenshot. Current look: The top and bottom of the box are filled with the background color until the edge https://i.stack.imgur.com ...

React client side componentDidMount function encountering issues (server side rendering)

Greetings to the Stackoverflow community Apologies in advance if my explanation is not clear enough When a user directly types a URL, the server makes a request, fetches the corresponding data, and renders it on the screen flawlessly. However, when a us ...

Setting up paths to bypass authentication on an Express website

Currently, I am in the process of developing an application using node and express. I have implemented a passport authorization middleware for all routes as part of my highly modular approach to building the app. One challenge I have encountered is when tr ...

Wcf Service does not define Angular JS methods

I am utilizing a WCF Service within an AngularJS application. The WCF Service is functional, and I am attempting to display a list of user records from a SQL database. However, upon running the application, I encountered the following errors: angular.js: ...

Execute the function if the text or value begins with a certain character

I'm trying to determine whether the text within a span starts with the letter "x" and then execute a function. I've come across using "^" in strings for this purpose, but am having trouble implementing it to check the text... <span>xfoo&l ...

How can we develop an AJAX chat with enhanced scrolling capabilities?

Could someone provide me with some examples on how to achieve this task? I already have some HTML code: <div id="chatDisplay"> </div> <input type="text" id="message" /><input type="button" id="send" value="Send" /> Next, I have so ...

Troubleshooting my nodejs websocket chat for message sending glitches

The chat system is built on nodejs using websockets from socket.io library. While I have a client that also utilizes websockets from socket.io, I'm facing challenges in making the two communicate effectively. The issue seems to be with the client not ...

Error message: The object does not have the necessary support for the property or method 'modal'

When attempting to display a modal pop-up to showcase details of a selected record in a grid, I encounter an issue. Despite setting the values for each control in the modal pop-up, it fails to open. I have ensured that all necessary references are included ...

A method of binding data from an array of objects in Vue using v-bind

I am tasked with rendering a board that is 20x15 and placing creatures on it. The information on where to place the creatures is stored in this.creaturesOnBoard within the gameEngine. My plan is to take X and y coordinates, then check if a creature exists ...

Jquery auto-suggest form validator

I have implemented a search dropdown menu using jQuery. Everything is working fine, and the 'not match' message displays properly when entering data that does not match any items. However, if I select an item from the dropdown and then modify it ...