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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:24:20+00:00 2026-05-27T23:24:20+00:00

I’ve been searching long for an answer (on SO too; I know this is

  • 0

I’ve been searching long for an answer (on SO too; I know this is not a properly “fresh” question) but I did not find a solution to my problem yet. I have a WCF REST service, defined as follows:

    [OperationContract]
    [WebInvoke(Method = "GET",
       ResponseFormat = WebMessageFormat.Json,
       BodyStyle = WebMessageBodyStyle.Bare,
       UriTemplate = "json/getUserOperations")]
Response<List<Operation>> GetUserOperations();

with this web.config:

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="WS_REST.DataServiceBehavior">
                 <serviceMetadata httpGetEnabled="true" />
                 <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
            <behavior name="web">
                <webHttp/>     
            </behavior>      
        </endpointBehaviors>
    </behaviors>    
    <services>
        <service behaviorConfiguration="WS_REST.DataServiceBehavior" name="WS_REST.DataService">
            <endpoint address="" binding="webHttpBinding" contract="WS_REST.IDataService" behaviorConfiguration="web">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>

This works well if called from browser. But if I call this in jquery ajax, as follows:

$.ajax({
        url: "http://localhost:1996/DataService.svc/json/getUserOperations",
        type: "GET",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        processdata: true,
        success: processReceivedData,
        error: onError,
        complete: function () { alert('completed'); }

 });

the service returns me a “405 Method not allowed” message. These are the headers of the request and of the response message:

    OPTIONS http://localhost:1996/DataService.svc/json/getUserOperations HTTP/1.1
    Host: localhost:1996
    User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20100101 Firefox/8.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding: gzip, deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Connection: keep-alive
    Origin: http://localhost:2100
    Access-Control-Request-Method: GET
    Access-Control-Request-Headers: content-type

    HTTP/1.1 405 Method Not Allowed
    Server: ASP.NET Development Server/9.0.0.0
    Date: Mon, 14 Nov 2011 16:28:58 GMT
    X-AspNet-Version: 2.0.50727
    Set-Cookie: ASP.NET_SessionId=0bd0cdyhwyvmuauqcbasvp45; path=/; HttpOnly
    Cache-Control: private
    Content-Type: text/html; charset=UTF-8
    Content-Length: 1024
    Connection: Close

So I fell into this, finding out that it could be some issue related to cross-domain calls, and then I modified my OperationContract as follows:

    [OperationContract]
    [WebInvoke(Method = "*",
       ResponseFormat = WebMessageFormat.Json,
       BodyStyle = WebMessageBodyStyle.Bare,
       UriTemplate = "json/getUserOperations")]
Response<List<Operation>> GetUserOperations();

In this way, the request seems to be correctly served, as the headers show:

    OPTIONS http://localhost:1996/DataService.svc/json/getUserOperations HTTP/1.1
    Host: localhost:1996
    User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20100101 Firefox/8.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding: gzip, deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Connection: keep-alive
    Origin: http://localhost:2100
    Access-Control-Request-Method: GET
    Access-Control-Request-Headers: content-type

    HTTP/1.1 200 OK
    Server: ASP.NET Development Server/9.0.0.0
    Date: Mon, 14 Nov 2011 16:45:19 GMT
    X-AspNet-Version: 2.0.50727
    Set-Cookie: ASP.NET_SessionId=as4tch55yulzc32fzxsefh2y; path=/; HttpOnly
    Cache-Control: private
    Content-Type: application/json; charset=utf-8
    Content-Length: 793
    Connection: Close

The response message actually contains the valid json data which I requested. By the way, the jquery.ajax function still trigger the error event… I don’t understand why, as the response seems correctly received.
Does anyone notice something wrong?

Regards!

  • 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-27T23:24:21+00:00Added an answer on May 27, 2026 at 11:24 pm

    The solution is here: http://www.codeproject.com/KB/ajax/jQueryWCFRest.aspx

    I’ve done as explained in “The cross-domain issue” paragraph and all works.

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

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

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.