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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:38:53+00:00 2026-06-07T14:38:53+00:00

I have a page containing links to some files. I basically need to access

  • 0

I have a page containing links to some files.

I basically need to access the source of the page for parsing it then and obtaining all the hyperlinks to the files.

My code is something like this (some piece of code I’ve found in many places on the net ..):

    "private static byte[] ReadImageFromUrl(string url)
    {
        var myReq = (HttpWebRequest)WebRequest.Create(url);

        myReq.Timeout = 10000;

        WebResponse myResp = myReq.GetResponse();

        Stream stream = myResp.GetResponseStream();

        List<byte> bytesList = new List<byte>();

        using (var br = new BinaryReader(stream))
        {
            try
            {
                while (true)
                {
                    var b = br.ReadByte();
                    bytesList.Add(b);
                }
            }
            catch (Exception)
            {}

            br.Close();
        }

        myResp.Close();

        return bytesList.ToArray();
    }"

Now the problem is I get “System.Net.WebException: The remote server returned an error: (500) Internal Server Error.” when calling “myReq.GetResponse()” – examining the error I see that the status is ‘ProtocolError’.

The response property of the WebException object contains some server error ..(although when opening it from the browser it opens correctly) …also when I call this function with the url of one of my files I get the same ProtocolError status, but the 404 error …

Please give any hint how could I solve it… or any other possibility of accomplishing this task.

Thanks !

  • 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-07T14:38:54+00:00Added an answer on June 7, 2026 at 2:38 pm

    My new code after using Fiddler is:

    private static byte[] ReadFileFromUrl(string url)
    {
        var myReq = (HttpWebRequest)WebRequest.Create(url);
        myReq.Accept = const_AcceptHeader;                
        myReq.Headers.Set(const_AcceptLanguageHeaderName, const_AcceptLanguageHeader);
        myReq.UserAgent = const_AcceptUserAgentHeader;
        myReq.CookieContainer = new CookieContainer();               
        myReq.KeepAlive = true;
        myReq.Timeout = Int32.Parse(ConfigSettings.RequestPageTimeout) * 1000;
        WebResponse myResp = null;
        List<byte> bytesList = null;
        myResp = myReq.GetResponse();
        Stream stream = myResp.GetResponseStream();
        bytesList = new List<byte>();
        using (var br = new BinaryReader(stream))
        {
            try
            {
                while (true)
                {
                    var b = br.ReadByte();
                    bytesList.Add(b);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
    
            br.Close();
        }                
    
        return bytesList.ToArray();
    }
    

    All variables that start with const_ are taken from Fiddler.

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

Sidebar

Related Questions

I have a overview page containing a list with some links from which multiple
Hi I have this html page containing some links in it which are at
I have a HTML page containing follwing links <a class=out href=www.a.com/hgfgtsdfdffsdfsdf>sdfsssdfddf</a> <a href=www.a.com/hgfgt>dsfdsf</a> <a
I have a master page which containing few CSS links and java scripts. <html
I have a page (telerik:RadPage) containing few grids and some nested controls and I
all my problem is as follows: I have a page containing an addthis-button. Normally,
Here's my scenario: I have a page containing several links; each link is meant
I have a div containing some content, in which there are some links. The
I have a page containing a PrimeFaces (2.2.1) Editor component, a Refresh button and
I have a page containing a control called PhoneInfo.ascx. PhoneInfo is dynamically created using

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.