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

The Archive Base Latest Questions

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

I am doing a cross-domain json post utilizing asp.net web api. On my service

  • 0

I am doing a cross-domain json post utilizing asp.net web api. On my service / server side I have the following method that response to the POST request:

// POST api/<controller>
public HttpResponseMessage Post(Customer newCustomer)
{
    DataClassesDataContext db = new DataClassesDataContext();
    var response = Request.CreateResponse<Customer>(HttpStatusCode.Created, newCustomer);

    db.Customers.InsertOnSubmit(newCustomer);
    db.SubmitChanges();

    string uri = Url.Link("DefaultApi", new { id = newCustomer.Id });
    response.Headers.Location = new Uri(uri);

    return response;
}

And on the client side, which run on a different port number (i.e. cross-domain), I am using the following jQuery code:

<body>

<input type="button" value="click me" onclick="hello()" />

<script type="text/javascript">
    function hello() {
        //SEE: http://stackoverflow.com/questions/5241088/jquery-call-to-webservice-returns-no-transport-error
        $.support.cors = true;

        //var jsonObjects = [{ Name: "Name1", CellphoneNum: 1234657911 }];

        $.ajax({
            url: "http://localhost:26037/api/customer",
            type: "POST",
            crossDomain: true,
            data: { Name: "Name321", CellphoneNum: 1234657922 },
            dataType: "json",

            success: function (result) {
                alert("Success");
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert('Thrown Error: ' + thrownError);
                alert('xhr status: ' + xhr.status);
            }
        });
    }
    </script>
</body>

My issue is that, from the client side, on IE the success alert message will be displayed and the data will be inserted to the database using the LINQ code in my POST method. However, using Chrome or Firefox the data will also get inserted to the database and LINQ code will be executed successfully but a message box with an empty string error and a 0 xhr status will be displayed.

Why is it only reporting an error on Firefox and Chrome while the data get posted and successfully processed in the server?

  • 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:52:11+00:00Added an answer on June 13, 2026 at 5:52 pm

    It looks like browsers don’t do a good job at reporting xhr errors. The tutorials below may help you out. Also, if you haven’t done so already, make sure to set the “Access-Control-Allow-Origin” header on the server side to the client domains you want to allow or “*” to allow all cross domain requests.

    General CORS tutorial: http://www.html5rocks.com/en/tutorials/cors/

    ASP.net and CORS:
    http://encosia.com/using-cors-to-access-asp-net-services-across-domains/

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

Sidebar

Related Questions

I am doing a cross domain post in .net, but in net they have
I am doing a cross-domain fetch from a ASP.NET page using Jquery-JSONP My ASP.NET
I'm making a cross-domain POST request and have set up headers in Rails 3.2
I am working on creating a RESTful API that supports cross-domain requests, JSON/JSONP support,
I'm doing some fairly simple cross-platform TCP socket programming. I have unfortunately found out
I am doing a cross domain request using $.ajax . It works on Firefox
XMLHttpRequest s require CORS to work cross-domain. Similarly for web fonts, WebGL textures, and
I have 2 ASP.Net applications in a solution. One is pretty much a testing
I'm trying to call web service for few hours. I have added clientaccesspolicy.xml: <?xml
I am using Ajax do do cross domain calls using JSON, and the script

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.