I wanted to check the status code that comes back as response from the HttpWebResponse. So I used the following code -
res = (HttpWebResponse) req.GetResponse();
It's working great, but if I wanted to let the server know a date when I visited the server last using "IfModifiedSince" 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 "IfModifiedSince" 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 "IfModifiedSince" 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.