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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:27:14+00:00 2026-05-23T18:27:14+00:00

I am using an HttpWebRequest and passing in an Address which is an IP.

  • 0

I am using an HttpWebRequest and passing in an Address which is an IP. I then set the host to a garbage value. When I call GetResponse() I am getting an OK even though I would expect this to fail since the host is garbage.

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(String.Format("http://10.10.10.10/Default.aspx"));
request.Host = "blah.blah.blah";
request.ContentType = "text/xml";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
    if (response.StatusCode == HttpStatusCode.OK) { /*always enters here */ }
}

Why is the response coming back as OK? Shouldn’t the garbage host cause this to fail?

  • 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-23T18:27:15+00:00Added an answer on May 23, 2026 at 6:27 pm

    HttpWebRequest.Host Property:

    Get or set the Host header value to use in an HTTP request independent from the request URI.

    Using the Host property to explicitly specify a custom Host header value also affects areas caching, cookies, and authentication. When an application provides credentials for a specific URI prefix, the applications needs to make sure to use the URI containing the value of the Host header, not the target server in the URI.

    So there is no effect of .Host to the general request, you change some additional behavior.

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

Sidebar

Related Questions

I've been using HttpWebRequest/HttpWebResponse lately and I'm getting encoding problems. HttpWebResponse.CharacterSet doesn't always represent
I'm trying to make an SSL call using HTTPWebRequest and its continually failing saying
I have a task to perform an HttpWebRequest using Task<WebResponse>.Factory.FromAsync(req.BeginGetRespone, req.EndGetResponse) which can obviously
Using HttpWebRequest, I can call XDocument.Save() to write directly to the request stream: XDocument
I'm using HTTPWebRequest with a proxy. I have noticed if I set KeepAlive to
I just noticed that using the .NET HttpWebRequest , I wasn't getting gzip'd contents
I'm trying to POST data to an external url using HttpWebRequest, then i need
I'm using HttpWebRequest and I get error when execute GetResponse(). I using this code:
I'm using HttpWebRequest to pull down XML, and POST data back to a 'WebService'
I'm using HttpWebRequest to download data from the website, and I noticed a bug

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.