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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:59:24+00:00 2026-06-13T04:59:24+00:00

I am following this tutorial to build my first Asp.net Web API in a

  • 0

I am following this tutorial to build my first Asp.net Web API in a Web Form website but I am facing an issue. I have created two projects:

  1. host project for the definition of the web service
  2. client project to consume the web
    service.

Now my issue is that if I navigate to my web api URL using a web browser ex) http://localhost:39930/api/products/ then this works perfectly and an XML or Json data is returned depending on the browser.

However, if I use the web service URL of the in my client website then nothing get returned!

Here is how I call the web service from my client website:

<table>
    <thead>
        <tr>
            <th>Name</th>
            <th>Price</th>
        </tr>
    </thead>
    <tbody id="products">
    </tbody>
</table>

 <script type="text/javascript">
     function getProducts() {
         $.getJSON("http://localhost:39930/api/products",
             function (data) {
                 $('#products').empty(); // Clear the table body.

                 // Loop through the list of products.
                 $.each(data, function (key, val) {
                     // Add a table row for the product.
                     var row = '<td>' + val.Name + '</td><td>' + val.Price + '</td>';
                     $('<tr/>', { text: row })  // Append the name.
                         .appendTo($('#products'));
                 });
             });
     }

     $(document).ready(getProducts);
</script>

And here is a snapshot of the request in firebug:

enter image description here

Notice that the response is empty.

So, am I doing something wrong here? Is there some configuration that should be added to allow a service to be remotely called?

Thanks in advance.

  • 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-13T04:59:25+00:00Added an answer on June 13, 2026 at 4:59 am

    It is because your host project and client project are running on different ports which is violating the same origin policy and its prohibited. See the details here http://en.wikipedia.org/wiki/Same_origin_policy

    If you want this to work, you can use jsonp instead of json. Have a look at this article http://www.jquery4u.com/json/jsonp-examples/#.UISVAo3iYsc

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

Sidebar

Related Questions

i have made a simple php contact form following this tutorial: http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme The big
Following this tutorial (http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/handling-concurrency-with-the-entity-framework-in-an-asp-net-mvc-application), I learned how to save data and do concurrency checks
I am following the first example in this tutorial: http://ruportbook.com/printable_documents.html , but I'm getting
I am following this tutorial to build my first Java 3D application. I included
http://developer.android.com/training/basics/firstapp/building-ui.html I have been following this tutorial, but I have two errors, both R
I was following this tutorial , but for the life of me I cant
I've made a hello world module for orchard following this tutorial http://docs.orchardproject.net/Documentation/Building-a-hello-world-module I've opened
I am following this tutorial http://railscasts.com/episodes/29-group-by-month and have built a system to allow a
I'm following the Android developers tutorial to build the first application. I did precisely
I tried following this tutorial from the author's github repository, but unsuccessfully. When I

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.