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

  • Home
  • SEARCH
  • 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 8011569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:03:19+00:00 2026-06-04T19:03:19+00:00

I try to consume a WCF service (REST) using ajax (xmlHttpRequest). The service require

  • 0

I try to consume a WCF service (REST) using ajax (xmlHttpRequest). The service require Basic authentication.

my ajax call is :

 var httpRequest = new XMLHttpRequest();
         httpRequest.onreadystatechange = function () {
             if (httpRequest.readyState == 4) {
                 if (httpRequest.status == 200) {
                     //do some stuff
                 }
             }

         };
         httpRequest.open('PUT', 'http://localhost:59000/v1/users/1', true, 'user1', 'user1');
         httpRequest.withCredentials = "true";
         //must authenticate both..in open() but also set header manually ...cf http://stackoverflow.com/questions/1358550/xmlhttp-request-basic-authentication-issue
         httpRequest.setRequestHeader('Auhtorization', 'Basic user1:user1');
         httpRequest.setRequestHeader('Accept', 'application/json');
         // overridemimeType() does not set content type header .... don't know why ?
         httpRequest.setRequestHeader('Content-Type', 'application/json');
         var params = { "UserName": "user1" };
         var requestBodyString = JSON.stringify(params);
         httpRequest.send(requestBodyString);

The way I first handle the request on the server side is the following

        HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin",
                      crossDomain);

        //preflight request : cf https://developer.mozilla.org/en/http_access_control 
        if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
        {
            HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods",
                          "GET, POST, PUT, DELETE");
            HttpContext.Current.Response.AddHeader("Access-Control-Allow-Credentials", "true");

            HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, Accept, DummyOneForTest");

            HttpContext.Current.Response.AddHeader("Access-Control-Max-Age",
                          "1728000");
            HttpContext.Current.Response.End();
        }

My browser sends me the error “Request header field Auhtorization is not allwed by Access-Control-Allow-Headers” but as you can see it is whitin the response header.

Moreover when I try with Fiddler everything is fine and I even have the header dummy one allowed.

So I am really confused, if anyone can help, please do !

Thanks

  • 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-04T19:03:21+00:00Added an answer on June 4, 2026 at 7:03 pm

    Got it, while running you server on “use visual studio development server” exception is thrown when you try to add a header (second code block) : “this operation require IIS integrated pipeline mode”.

    the solution is in the app config to “use IIS web server”

    Accordingly to this link http://msdn.microsoft.com/en-us/library/d14azbfh.aspx#addexceptionscommand

    You can not ask Visual Studio to tell you when exception is thrown and I missed it.

    Thanks

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

Sidebar

Related Questions

I try to consume WCF service in Silverlight project but in ass Reference dialog
I'm trying to create a web service client using CXF to consume a WCF
I have exposed my REST API service using WCF Service Library and started by
I am using NuSOAP to try to consume a Web Service built in Java.
I get the following error when i try to consume my wcf service Could
try { using (MapDataContainer ent = new MapDataContainer()) //is an autogen'd EF object {
I have developed a sample WCF REST service that accepts that creates an Order
I am trying to consume a WCF service in a class library by adding
I have made a REST Web service, that works with Visual Studios WCF Test
I'm trying to consume a WCF webservice using the RPC capabilities of the Protobuf-net.

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.