Results 1 to 2 of 2

Thread: how to get "304 not modified" and such?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Location
    I'm right here!
    Posts
    849

    Question how to get "304 not modified" and such?

    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

    Dekel C.

  2. #2
    Hyperactive Member wordracr's Avatar
    Join Date
    Aug 2001
    Posts
    281

    Re: how to get "304 not modified" and such?

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width