Help me understand something about HttpWebResponse

Hi all

I have some something weird with the HttpWebResponse and I was hoping someone could help me understand what is going on.

This problem is already fixed but for my own curiosity I was hoping someone would be able to shed some light.

Here is a simlified version of the code:

string sHtmlFile = "http://localhost/test.html";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sHtmlFile);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

The weirdness is that iis will file lock test.html if it is > 30kb but will not lock it if it is below 30kb. 30kb is a rough estimate i havent actually checked the bytes.

I know the solution is to add response.Close(); but i was hoping someone out there could speculate on how/why this would be happening.

It seems weird to me that it would lock a 35kb html file but not a 25kb html file

Thanks
Jay

Comments

  • : Hi all
    :
    : I have some something weird with the HttpWebResponse and I was
    : hoping someone could help me understand what is going on.
    :
    : This problem is already fixed but for my own curiosity I was hoping
    : someone would be able to shed some light.
    :
    : Here is a simlified version of the code:
    :
    : string sHtmlFile = "http://localhost/test.html";
    : HttpWebRequest request =
    : (HttpWebRequest)WebRequest.Create(sHtmlFile);
    : HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    :
    : The weirdness is that iis will file lock test.html if it is > 30kb
    : but will not lock it if it is below 30kb. 30kb is a rough estimate
    : i havent actually checked the bytes.
    :
    : I know the solution is to add response.Close(); but i was hoping
    : someone out there could speculate on how/why this would be happening.
    :
    : It seems weird to me that it would lock a 35kb html file but not a
    : 25kb html file
    :
    : Thanks
    : Jay
    :
    :
    It probably has to do with the way IIS buffers the html files. For a 25 kB file, it can read the file in one go, while any larger file is streamed to the client. While streaming a file to a client, IIS protects the data form writing. This is pure speculation but it seems logical.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion