HttpWebResponse - Status Code Check Issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nukiee
    New Member
    • Jan 2007
    • 4

    HttpWebResponse - Status Code Check Issue

    I wanted to check the status code that comes back as response from the HttpWebResponse . So I used the following code -

    res = (HttpWebRespons e) req.GetResponse ();

    It's working great, but if I wanted to let the server know a date when I visited the server last using "IfModifiedSinc e" variable of the "req" object, the above piece of code throws an exception if the content was not modified since the time that I entered in the "IfModifiedSinc e" variable. At this point I need to analyze the exception to see if the server threw a 304 error or not and re-create an error message.

    I know that HttpWebResponse .HttpStatusCode could give me some status information, but in that case it seems that I cannot use the "IfModifiedSinc e" variable.

    Problem: If I do not let the server know the last time I visited, how would the server let me know if the content was modified or not, and how would I restrict myself going to the server and downloading the content every time I make a request?

    Can anyone provide any better solution, please? Thanks.
Working...