Home > Articles > Home & Office Computing > Mac OS X

  • Print
  • + Share This
Like this article? We recommend

Building the ASP.NET Message-Receiver Application

When a file system state change occurs on the OS X machine, a message is sent to a web site on the interested Windows machine, as mentioned earlier. I created an ASP.NET page to receive messages about the OS X machine in the form of HTTP requests. When the ASP.NET message-receiving page gets a request from the OS X File Watcher, it parses out from the query string the message sent from the Mac file system, and processes that message. In this case, the message is sent to a database and the data passed to it from the OS X machine is returned as an indication that the data has been processed. The following code is the ASP.NET server-side script (written in Visual Basic .NET) that's used by the Windows web site:

<%@ Page Language="vb" AutoEventWireup="false"%>
 <script runat=server>
  Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here

    Dim filName As String = ""
    Dim filMessage As String = ""
    Dim filDateStr As String = ""

    If Not Page.Request.Item("FileName") Is Nothing Then
      filName = CType(Page.Request.Item("FileName"), String)
    Else
      filName = ""
    End If

    If Not Page.Request.Item("FileMessage") Is Nothing Then
      filMessage = CType(Page.Request.Item("FileMessage"), String)
    Else
      filMessage = ""
    End If

    If Not Page.Request.Item("FileDateStr") Is Nothing Then
      filDateStr = CType(Page.Request.Item("FileDateStr"), String)
    Else
      filDateStr = "")
    End If

    'Do some data access stuff here with the passed parameters

    if filDateStr.length > 0 then
      Response.Write("->" & filMessage & ":" & filName & ":" & filDateStr)
    else
      Response.Write("--" & filMessage & ":" & filName & ":" & Now().ToLongTimeString())
    end if
  End Sub
</script>
  • + Share This
  • 🔖 Save To Your Account