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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:09:03+00:00 2026-06-03T00:09:03+00:00

How would I call an ASP.NET Web API directly from code-behind? Or should I

  • 0

How would I call an ASP.NET Web API directly from code-behind? Or should I be calling my javascript function that calls the getJSON method from code-behind?

I usually have something like:

    function createFile() {
        $.getJSON("api/file/createfile",
        function (data) { 
            $("#Result").append('Success!');
        });
    }

Any pointers appreciated. TIA.

*I’m using WebForms.

  • 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-03T00:09:05+00:00Added an answer on June 3, 2026 at 12:09 am

    If you must call the web service itself, you can try using HttpClient as described by Henrik Neilsen.

    Updated HTTPClient Samples

    A basic example:

    // Create an HttpClient instance 
    HttpClient client = new HttpClient(); 
    
    // Send a request asynchronously continue when complete 
    client.GetAsync(_address).ContinueWith( 
        (requestTask) => 
        { 
            // Get HTTP response from completed task. 
            HttpResponseMessage response = requestTask.Result; 
    
           // Check that response was successful or throw exception 
            response.EnsureSuccessStatusCode(); 
    
            // Read response asynchronously as JsonValue
            response.Content.ReadAsAsync<JsonArray>().ContinueWith( 
                        (readTask) => 
                        { 
                            var result = readTask.Result
                            //Do something with the result                   
                        }); 
        }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My requirement is to call WCF web service from ASP.NET code behind and pass
Is it possible to call a function within an asp.net web application from outside
I’m doing maintenance on an asp.net web app that uses remoting to call a
I was wondering how you would call a getter function from another class in
I have an ASP.NET web form. This web form has an event handler that
I am building an ASP.NET web service that will be used internally in my
I am currently moving an ASP.NET web-project from an IIS 6 to a IIS
When making calls to a webservice from an asp.net web application, to avoid creating
I have an ASP.NET web site that has a entities version 4.0 DAL. I
I'm attempting to eliminate the duplication accross two ASP.NET web projects that use exactly

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.