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 6758933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:51:59+00:00 2026-05-26T13:51:59+00:00

My service is secured with basic authentication set in IIS and i am try

  • 0

My service is secured with basic authentication set in IIS and i am try to get data from service with Jquery.

Cross domain calls is enabled.

I have next request headers

Host http:\\service.com
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-gb,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection keep-alive
Origin null
Access-Control-Request-Me... GET
Access-Control-Request-He... authorization
Pragma no-cache
Cache-Control no-cache

Responses

Content-Type text/html
Server Microsoft-IIS/7.5
WWW-Authenticate Basic realm="172.27.131.5"
X-Powered-By ASP.NET
Access-Control-Allow-Orig... *
Access-Control-Allow-Head... *
Date Fri, 12 Aug 2011 08:07:29 GMT
Content-Length 1293

Code

 $.ajax({
     headers : {
        "Authorization" : "Basic TVNF3TQtU1BGMjAx6C12bVxzbW4ydHBvaW50OlF3Z5J0eSEyM6Q1"
     },
     type: "GET",
     url: url,
     contentType: "application/json; charset=utf-8",
     dataType: "json",
     success: function(data) {
      alert('ok!');
      formatData(format_type,data);
     },
     error: function(jqXHR, textStatus, errorThrown) {
          alert(textStatus + ' / ' + errorThrown);
     }
  });

also i tried to set

 beforeSend : function(xhr) {
      xhr.setRequestHeader("Authorization", "Basic " + Base64.encode(username + ':' + password));
        },

But i have next error:

Request header field Authorization is not allowed by Access-Control-Allow-Headers

What i am doing wrong?

  • 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-05-26T13:52:00+00:00Added an answer on May 26, 2026 at 1:52 pm

    Try adding the following code to the global.asax in your WCF project (only works when hosted in iis):

    protected void Application_BeginRequest(object sender, EventArgs e)
    {
        EnableCrossDomainAjaxCall();
    }
    
    private void EnableCrossDomainAjaxCall()
    {
        HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
    
        if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
        {
            HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");
            HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, Accept");
            HttpContext.Current.Response.End();
        }
    }
    

    Jquery issues an OPTIONS call to the WCF service to check if the call is allowed. You’ll have to match the exact header. You can also download an example here: http://sameproblemmorecode.blogspot.com/2011/10/creating-secure-restfull-wcf-service.html.

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

Sidebar

Related Questions

I need an advice from people who already used base authentication in WCF Service.
I am attempting to add BASIC authentication to a RESTful web service that I
I have a REST web service protected with custom basic authentication . Now I
I'm trying to get secure web service connectivity on the iPhone over https via
I have a basic xml-rpc web service service running. What is the simplest way(I'm
I'd like to make requests from an iphone app to a web service I've
I have hosted one WCF Service on the Azure platform and in web.config enabled
Trying to do basic SSL-authenticated Web Service using Visual Studio 2008 .NET 3.5 Service
I'm trying to get going with a new WCF service. The service was working
I have a .Net service running on IIS 6 and WCF that I want

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.