Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8771113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:42:20+00:00 2026-06-13T17:42:20+00:00

I have an ASP.NET Web API application running on my local instance of IIS.

  • 0

I have an ASP.NET Web API application running on my local instance of IIS. The web application is configured with CORS. The Web API method I am calling reads something like:

[POST("/API/{foo}/{bar}")]
public String DoSomething(String foo, String bar)
{
    return "Hello, World!";
}

Client side, I’m running the following request:

$.ajax({
    url: "http://machine/API/Foo/Bar",
    type: "POST",
    success: function (data) {
        console.log("Success: " + data);
    },
    error: function (xhr, status, message) {
        console.log("Failure: " + status + ", " + message);
    }
});

The corresponding console log within Firefox 15.0.1 reads as:

test.html (line 38)
POST http://machine/API/Foo/Bar

200 OK
        112ms   
jquery-1.7.2.js (line 8240)

Success: "Hello, World!"

This works flawlessly when I’m accessing my local IIS server as well as when I have it accessing the corresponding URL for the IIS Express development instance within Visual Studio.

When I add a single request header, anything at all, the following request fails when made against my local IIS server:

$.ajax({
    url: "http://machine/API/Foo/Bar",
    type: "POST",
            onBeforeSend: function (xhr, settings) {
                xhr.setRequestHeader("A", "B");
            },
    success: function (data) {
        console.log("Success: " + data);
    },
    error: function (xhr, status, message) {
        console.log("Failure: " + status + ", " + message);
    }
});

The ever so verbose log message I see is:

Failure: error, 

The same POST request is successful when made against the IIS Express development instance within Visual Studio.

In Fiddler, the previous two requests go through without failure regardless of whether I’m targeting the full IIS server or IIS Express within Visual Studio:

// Request
POST http://machine/Foo/Bar HTTP/1.1
Host: machine
Content-Length: 0

// Response
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 38
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 09 Oct 2012 20:16:29 GMT

"Hello, World!"

The permutations {With Headers, Without Headers} x {Full IIS, IIS Express} all produce identical output within Fiddler.

In short: Why does having request headers set cause the AJAX call to fail against my local fully fledged IIS instance?

Furthermore, why does my requests succeed in Fiddler but not in my Javascript code? This is a serious deal breaker if I can’t set request headers in a proper IIS instance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:42:22+00:00Added an answer on June 13, 2026 at 5:42 pm

    The actual underlying issue with my CORS problem was related to the pipeline utilized by IIS 7.

    When IIS 7 is operating under the Classic Pipeline, requests were not being preflighted with the OPTIONS request. They would fail silently as I described in my question. I saw this in the Net tab of Firebug and via interactive debugging with the Thinktecture IdentityModel library explicitly included as a project to my solution.

    But when IIS 7 operates under Integrated Pipeline, CORS is respected. POST requests and requests with custom headers are correctly preflighted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASP.NET MVC 4 application with Web API. It's working great. But
I have an asp.net web api application which is acting as a Relay to
I have an ASP.NET 4.0 web application which uses a third-party API for external
I have an ASP.NET Web API application, with an ApiController that features asynchronous methods,
I am developing a ASP.Net Web API application and I have used AuthorizeAttribute for
I have an ASP.NET MVC 4 application which uses the new ASP.NET Web API.
We currently have a classic ASP.NET web application which serves as our API. It
I am running a very simple Web application (Asp.Net MVC3) on Win 7 IIS.
I have an ASP.NET Web API single page application (all HTML5/CSS3/JavaScript talking to the
I have a layered web application that I built with ASP.NET MVC 4, WebAPI

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.