question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get the status code of the response?

See original GitHub issue

I do this but I have not found on how to get the status code of the response. How to get the status code of the response?

       public sealed class WebReader
        {
            private IDocument _ashDocument;

            public async Task Load(string Url)
            {
                IConfiguration config = Configuration.Default.WithDefaultLoader().WithJavaScript().WithCss();
                _ashDocument = await BrowsingContext.New(config).OpenAsync(Url);
                await Task.WhenAll(_ashDocument.Requests);
            }

            public IHtmlCollection<IElement> Images { get { return _ashDocument.QuerySelectorAll("img"); } }             

            public IHtmlCollection<IElement> Links { get { return _ashDocument.Links; } } 
        }

        static void Main(string[] args)
        {
            WebReader wReader = new WebReader();  

            // HTTP Status code: 200
            wReader.Load("http://blogs.msdn.com/b/dotnet/").Wait();

            // HTTP Status code: 404
            wReader.Load("http://httpbin.org/status/404").Wait();

             Console.ReadKey();
        }

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vickyRatheecommented, Jan 30, 2016

I was looking for the same and found this thread is closed, was this implemented in 0.9.4? any example?

0reactions
StephenGilboycommented, Sep 15, 2021

@bugproof and for anyone else wondering you can get the status on the document.

var document = await context.OpenAsync(url);
if (document.StatusCode == HttpStatusCode.NotFound)
{
   ...
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Response: status property - Web APIs - MDN Web Docs
The status read-only property of the Response interface contains the HTTP status codes of the response.
Read more >
How to Get the Status Code of a Fetch HTTP Response in ...
Simply call the status property on the response object to get the status code. Thanks for reading! If you want to learn about...
Read more >
HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:.
Read more >
Check HTTP Response Status Codes | Matthew Edgar
For a basic one-by-one analysis of a page, you can use header check tool like REDbot. Enter the URL of the page you...
Read more >
Get HTTP code from org.apache.http.HttpResponse
Use HttpResponse.getStatusLine() , which returns a StatusLine object containing the status code, protocol version and "reason".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found