Click here to Skip to main content
15,887,383 members
Home / Discussions / C#
   

C#

 
GeneralRe: Need help with Functions, ASAP! Pin
#realJSOP13-Apr-18 9:07
mve#realJSOP13-Apr-18 9:07 
GeneralRe: Need help with Functions, ASAP! Pin
Eddy Vluggen13-Apr-18 9:12
professionalEddy Vluggen13-Apr-18 9:12 
GeneralRe: Need help with Functions, ASAP! Pin
#realJSOP13-Apr-18 9:28
mve#realJSOP13-Apr-18 9:28 
AnswerRe: Need help with Functions, ASAP! Pin
#realJSOP13-Apr-18 9:10
mve#realJSOP13-Apr-18 9:10 
PraiseRe: Need help with Functions, ASAP! Pin
Eddy Vluggen13-Apr-18 9:15
professionalEddy Vluggen13-Apr-18 9:15 
GeneralRe: Need help with Functions, ASAP! Pin
#realJSOP13-Apr-18 9:33
mve#realJSOP13-Apr-18 9:33 
GeneralRe: Need help with Functions, ASAP! Pin
BillWoodruff13-Apr-18 18:54
professionalBillWoodruff13-Apr-18 18:54 
Questiongetting a 200 or what ever it is status_code not a ok Pin
sadsack12-Apr-18 9:04
sadsack12-Apr-18 9:04 
Hello
Below id my C# code for finding the status of a website. I get a ok, what I want is to get a 200.

C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace _200_Test2
{
    class Program
    {
        static void Main(string[] args)
        {

            {
                WebRequest request = WebRequest.Create("http://www.cnn.com/");
                try
                {
                    using (WebResponse response = request.GetResponse())
                    {
                        HttpWebResponse httpResponse = (HttpWebResponse)response;
                        Console.WriteLine(httpResponse.StatusCode);
                        Console.ReadKey();
                    }
                }
                catch (WebException e)
                {
                    using (WebResponse response = e.Response)
                    {
                        HttpWebResponse httpResponse = (HttpWebResponse)response;
                        Console.WriteLine("Error code: {0}", httpResponse.StatusCode);
                        using (Stream data = response.GetResponseStream())
                        {
                            string text = new StreamReader(data).ReadToEnd();
                            Console.WriteLine(text);
                        }
                    }
                }
            }
        }
    }
    
}


I try for days now to get a simple 200.
Maybe someone can look at this and tell me what I am going wrong.
Thank You
renny
AnswerRe: getting a 200 or what ever it is status_code not a ok Pin
Afzaal Ahmad Zeeshan12-Apr-18 9:23
professionalAfzaal Ahmad Zeeshan12-Apr-18 9:23 
GeneralRe: getting a 200 or what ever it is status_code not a ok Pin
sadsack17-Apr-18 13:59
sadsack17-Apr-18 13:59 
AnswerRe: getting a 200 or what ever it is status_code not a ok Pin
Richard MacCutchan12-Apr-18 21:38
mveRichard MacCutchan12-Apr-18 21:38 
GeneralRe: getting a 200 or what ever it is status_code not a ok Pin
sadsack17-Apr-18 14:02
sadsack17-Apr-18 14:02 
QuestionWrite a 2D array of objects in range Excel C# Pin
Gtari Abir12-Apr-18 5:29
Gtari Abir12-Apr-18 5:29 
AnswerRe: Write a 2D array of objects in range Excel C# Pin
Dave Kreskowiak12-Apr-18 7:29
mveDave Kreskowiak12-Apr-18 7:29 
QuestionValidate User Against Active Directory Pin
Kevin Marois11-Apr-18 10:23
professionalKevin Marois11-Apr-18 10:23 
AnswerRe: Validate User Against Active Directory Pin
Keviniano Gayo11-Apr-18 21:55
Keviniano Gayo11-Apr-18 21:55 
GeneralRe: Validate User Against Active Directory Pin
Kevin Marois12-Apr-18 5:47
professionalKevin Marois12-Apr-18 5:47 
GeneralRe: Validate User Against Active Directory Pin
Keviniano Gayo13-Apr-18 1:49
Keviniano Gayo13-Apr-18 1:49 
QuestionGetting a directory path if directory name is given Pin
NiKHiLMS11-Apr-18 3:17
NiKHiLMS11-Apr-18 3:17 
AnswerRe: Getting a directory path if directory name is given Pin
Richard MacCutchan11-Apr-18 3:32
mveRichard MacCutchan11-Apr-18 3:32 
GeneralRe: Getting a directory path if directory name is given Pin
NiKHiLMS11-Apr-18 21:38
NiKHiLMS11-Apr-18 21:38 
GeneralRe: Getting a directory path if directory name is given Pin
Jochen Arndt11-Apr-18 22:37
professionalJochen Arndt11-Apr-18 22:37 
GeneralRe: Getting a directory path if directory name is given Pin
NiKHiLMS11-Apr-18 22:51
NiKHiLMS11-Apr-18 22:51 
GeneralRe: Getting a directory path if directory name is given Pin
Jochen Arndt12-Apr-18 0:01
professionalJochen Arndt12-Apr-18 0:01 
AnswerRe: Getting a directory path if directory name is given Pin
MadMyche11-Apr-18 5:04
professionalMadMyche11-Apr-18 5:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.