Click to See Complete Forum and Search --> : how to get "304 not modified" and such?
dekelc
Jan 9th, 2006, 05:00 PM
hello!!
I need to make a function in my app, that will recieve a url and time.
the function returns true if the web page has been modified since the
given time, and false if it didn't.
I know I probably need to use the "GET" command, and see if it returns
"304 no modified" or not, but I don't know how to implement in c#...
can anyone help??
thanks
:wave:
wordracr
Jan 20th, 2006, 09:00 PM
Try this code (you'll need to convert it, but no biggy. Just ask if you need help on a specific area)
<%@ Page language="VB" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<html>
<head>
<SCRIPT runat="server">
Sub btnSubmit_Click(sender As Object, e As EventArgs)
Dim req As WebRequest = WebRequest.Create(txtURI.Text)
Try
Dim result As WebResponse = req.GetResponse()
Dim ReceiveStream As Stream = result.GetResponseStream()
Dim read() as Byte = new Byte(512) {}
Dim bytes As Integer = ReceiveStream.Read(read, 0, 512)
txtHTML.InnerHtml = ""
While (bytes > 0)
Dim encode As Encoding = System.Text.Encoding.GetEncoding("utf-8")
txtHTML.InnerHtml = txtHTML.InnerHtml & encode.GetString(read, 0, bytes)
bytes = ReceiveStream.Read(read, 0, 512)
End While
Catch Exc As Exception
txtHTML.InnerHtml = "Error retrieving page"
End Try
end sub
</SCRIPT>
If that's not the answer and you know how to do this in another language, post that. Someone will be more easily able to help you that way.
I found this link for more info for myself:
http://www.checkupdown.com/status/E304.html
and the code was from msdn!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.