Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

HttpWebResponse & Webservers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brent - 26 Oct 2005 17:11 GMT
I'm having odd problems with the HttpWebResponse class. Some servers are
 quite speedy, while others don't seem to want to talk to my code.
Consider the following pages*:

    http://planetbrent.com/test.aspx?url=http://www.yahoo.com
    http://planetbrent.com/test.aspx?url=http://www.msn.com
    http://planetbrent.com/test.aspx?url=http://www.sec.gov
http://planetbrent.com/test.aspx?url=http://sec.gov/Archives/edgar/data/1061165/
000090266405001703/0000902664-05-001703.txt


The first two return a "screen scrape" quite rapidly -- all-but
instantly. The third and fourth links -- both on the same server, I'm
guessing -- take several seconds (if you test them, please be patient!).
  The four pages are roughly the same size in bytes.

Viewing the slow pages in a normal browser from the same machine is
acceptably fast.

I'm thinking there may be an issue with the way the response comes back
from the server. Is it possible that some servers deliver data that's
confusing to the HttpWebResponse class?

I read something about bad chunking (or something like that) from Apache
servers, and that one possible solution was to get bytes instead of
lines. That might be a solution ... except that I need to read through
URLs like the fourth one line-by-line,  as each line gets parsed by
other parts of the code.

I'd sure appreciate any pointers on handling this situation!

--Brent

*Full source code for the page.
=========================================================
<%@ Page Language="C#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Data" %>

<script language="C#" runat="server">
string rowsdeclared = "";

public void Page_Load(Object sender, EventArgs e)
{
    string url = Request.QueryString["url"] != null ?
Request.QueryString["url"] : "http://www.yahoo.com";
    ctrlSF.Text = "Started: " +
System.DateTime.Now.ToString("HH:mm:ss") + " | ";
    ctrlText.Text = getHeader(url);
    ctrlSF.Text += "Finished: " + System.DateTime.Now.ToString("HH:mm:ss");
}

public string getHeader (string strURL)
{
    StringBuilder returnString = new StringBuilder();

    String strreturn;
    String thisRow = "";

    WebResponse objResponse;
    WebRequest objRequest = HttpWebRequest.Create(strURL);
    objResponse = objRequest.GetResponse();
   
    using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
    {
        while ((thisRow = sr.ReadLine()) != null)
       {
               returnString.Append(thisRow);
        }
    }
     return returnString.ToString();
}

</script>

<asp:Literal id="ctrlSF" runat="server" />
<asp:Literal id="ctrlText" runat = "server" />
Bruce Barker - 26 Oct 2005 19:19 GMT
you need to run a network trace and determine where the delays are. for
example, win2000 has a tendency to use piggyback acks when it shouldn't and
can cause delays over http.

-- bruce (sqlwork.com)

> I'm having odd problems with the HttpWebResponse class. Some servers are
> quite speedy, while others don't seem to want to talk to my code. Consider
[quoted text clipped - 77 lines]
> <asp:Literal id="ctrlSF" runat="server" />
> <asp:Literal id="ctrlText" runat = "server" />
Brent - 26 Oct 2005 21:02 GMT
Thanks, Bruce. I have Ethereal installed, but (frankly!) I don't have a
clue about all the bits of data it presents. There are a lot of
red-flagged lines, which I assume mean problems. Whatever. Funny thing:
two weeks ago this same code worked like a champ. Weird.

Is a network trace different from what Ethereal produces?

--Brent

> you need to run a network trace and determine where the delays are. for
> example, win2000 has a tendency to use piggyback acks when it shouldn't and
> can cause delays over http.
>
> -- bruce (sqlwork.com)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.