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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:56:40+00:00 2026-06-15T06:56:40+00:00

This is my code: 1 HttpClient client = new HttpClient(); 2 client.BaseAddress = new

  • 0

This is my code:

1 HttpClient client = new HttpClient();
2 client.BaseAddress = new Uri("http://localhost/");
3 HttpResponseMessage message = client.GetAsync("api/MyAPI").Result;
4 IEnumerable<string> supplies = 
                 message.Content.ReadAsAsync<IEnumerable<string>>().Result;
5 return View(supplies);

And the error occurs on line 3 Error:404

But When I use Visual Studio 2010 development server, no errors occur.

  • 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-15T06:56:42+00:00Added an answer on June 15, 2026 at 6:56 am

    Essentially you have to take care of the cases yourself here.

    For development the path to your API is :

    http://localhost/api/MyAPI
    

    And for production on IIS it is:

    http://localhost/WebAPITest/api/MyAPI
    

    The simplest way, which is what we do in fact at my company, is, put the base path into a configuration (Application Settings maybe) and then do this:

    Settings.BaseUrl = "http://localhost/";
    client.BaseAddress = new Uri(Settings.BaseUrl);
    

    When you deploy to IIS change Settings.BaseUrl to http://localhost/WebAPITest/.

    Ideally you could also drop the VS development server and debug on IIS. (This requires VS running with administrator rights)

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

Sidebar

Related Questions

I used this code in my Android application: import org.apache.http.client.methods.HttpPost; ... HttpClient httpclient =
I'm making a http get request like this: try { HttpClient client = new
i write this code in main.java ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); try{ HttpClient httpclient
So I've got some Java code that uses Jakarta HttpClient like this: URI aURI
I'm using something like this: HttpClient client = new DefaultHttpClient(); HttpGet request = new
I'm using following stupid code to download some data: HttpClient client = new DefaultHttpClient();
So I'm wondering in Java is this safe? HttpClient client = new DefaultHttpClient(); HttpResponse
I am calling a json webservice using the code HttpClient client = new DefaultHttpClient();
Here is my code: HttpClient client = new DefaultHttpClient(); client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, android); HttpGet request =
I am using System.Net.Http.HttpClient to access a rest service. This code compiles and runs

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.