C# -- HttpWebRequest and HttpWebResponse Use

Use a combination of HttpWebRequest and HttpWebResponse, To determine whether a web address can be accessed normally .

1. give an example

 class Program
{
static void Main(string[] args)
{
string strUrl = "https://www.baidu.com"; HttpWebRequest wreq = (HttpWebRequest)WebRequest.Create(strUrl);
HttpWebResponse wrsp = (HttpWebResponse)wreq.GetResponse(); if (wrsp.StatusCode == HttpStatusCode.OK)
{
Console.WriteLine(strUrl+ " --http response normal \r\n");
}
else
{
Console.WriteLine(strUrl + " --http response Something unusual happened !\r\n");
} Console.ReadKey();
}
}

2. Running results :

C# -- HttpWebRequest and HttpWebResponse More articles about the use of

  1. C# HttpWebRequest And HttpWebResponse Detailed explanation

    C# HttpWebRequest And HttpWebResponse Detailed explanation   http://www.codeproject.com/Articles/6554/How-to-use-HttpWebRequ ...

  2. Use HttpWebRequest as well as HttpWebResponse Read Http Remote files

      Home page > Miscellaneous Technology >.NET(C#)> Use HttpWebRequest as well as HttpWebResponse Read Http Remote files jackyhwei Published on 2010-08-15 21: ...

  3. HttpWebRequest and HttpWebResponse Summary of usage

    http://www.cnblogs.com/willpan/archive/2011/09/26/2176475.html http://www.cnblogs.com/lip0121/p/4539 ...

  4. utilize HttpWebRequest and HttpWebResponse obtain Cookie

    I have read an article about the use of JSoup Analyze the articles in the school library , Take a closer look. , It turned out to be the same school !! Since the other party is using java, Then I'll have a C# Okay , Although my basic language is java. C# No, JSoup Such a convenient East ...

  5. c# HttpWebRequest And HttpWebResponse stunt ( Reprint )

    c# HttpWebRequest And HttpWebResponse  stunt      If you want to do something , Grab , Or the function of automatic acquisition , Then come and study with me Http Ask for it. . This article will focus on Http On request Get and P ...

  6. C# simulation POST Submit Form ( Two )--HttpWebRequest as well as HttpWebResponse

    Last time I introduced the use of WebClient Submitted by POST request , This time, , I'll go on to another way HttpWebRequest as well as HttpWebResponse I think it's the same as last time WebClient The biggest difference is ...

  7. C# utilize HttpWebRequest and HttpWebResponse Simulated login website with verification code

    original text :C# utilize HttpWebRequest and HttpWebResponse Simulated login website with verification code We often encounter the need to program simulation login a website , If the website needs to fill in the verification code, how to simulate login ? This article ...

  8. utilize HttpWebRequest and HttpWebResponse obtain Cookie And realize simulated Login

    utilize HttpWebRequest and HttpWebResponse obtain Cookie And realize simulated Login tring cookie = response.Headers.Get("Set-Cookie ...

  9. C# Use HttpWebRequest and HttpWebResponse Upload file example

    C# Use HttpWebRequest and HttpWebResponse Upload file example 1.HttpHelper class : Copy the contents to the clipboard program code using System;using System.Colle ...

Random recommendation

  1. java selenium Topic two How to deal with it Table

    If you operate Table.   For example, I have a table.  table The order of the columns will change , The number of rows also changes . problem : If you get your age by name HTML Source code <html> <body ...

  2. 6、android Network programming

    1. be based on socket Usage of Server side : Start a server-side socket     ServerSocket svr = new ServerSocket(8989); Start listening for requests Socket s  ...

  3. POJ1845Sumdiv( Find all the factors and + Unique decomposition theorem )

    Sumdiv Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17387   Accepted: 4374 Descripti ...

  4. bzoj 3143 [Hnoi2013] wander ( greedy , Gauss elimination , The expectation equation )

    [ Topic link ] http://www.lydsy.com/JudgeOnline/problem.php?id=3143 [ The question ] Given an undirected graph , from 1 Go to the n, The score obtained by walking through an edge is the label of the edge , Ask one side ...

  5. Linux File search command find Usage arrangement (locate/find)

    Linux File search mainly includes :locate and find 1.locate Simple to use , Look up... From the database , Not in real time , usage : locate FILENAME Update database manually ( Time may be long ) updatedb 2 ...

  6. EXTJS4: stay grid Add the total line to

    extjs4 Very convenient to achieve a simple total ( In the case of no paging ): Its effect is realized in :Ext.grid.feature.Summary In this class Ext.define('TestResult', { extend ...

  7. turn :javascript object-oriented programming

    author :  Ruan Yifeng date : 2010 year 5 month 17 Japan Study Javascript, What's the hardest part ? I think ,Object( object ) The hardest . because Javascript Of Object The model is unique , It's not like any other language , Beginners ...

  8. ArcGIS Field calculator splits strings in fields

    ArcGIS Field calculator splits strings in fields example : There are three attribute data of length, width and height in one field , With x Division . for example sss For field name ( The field property is text type ), The data format is :100x200x300, Use the field calculator to store the three numbers separately ...

  9. abnormal -----freemarker.core.ParseException: Unexpected end of file reached

    freemarker Custom tag 1. Error description freemarker.core.ParseException: Unexpected end of file reached. at freemarker ...

  10. Luogu P3258 [JLOI2014] Squirrel's new home ( The tree chain splits )

    Squirrel's new home is a tree , I just renovated my new home a few days ago , The new home has n A room , And there are n-1 A branch connects , Every room is accessible to each other , And the route between the two rooms is unique . Oh my god , He actually lives in ” Trees “ On . Squirrel wants to invite Pooh to come ...