Hi Everyone,
I'm trying to implement a http handle (.ashx) using asp.net for an environment where the clients will be using serverxmlhttp to request information from the handler. Here is the code so far...
CLIENT.ASPX
<%@ Page Language="VB" %>
<%
On Error Resume Next
Dim myserver_url As String = "http://mydomain.com/Server.ashx"
Dim myparameters As String = "one=1&two=2"
Dim xmlhttp As Object
xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
xmlhttp.open("POST", myserver_url, False)
xmlhttp.Send(myparameters)
If xmlhttp.Status = 200 Then
Dim myresults As String = ""
myresults = xmlhttp.responsetext
Response.Clear()
Response.Write("<html><body><h1>" & myresults & "</h1></body></html>")
End If
xmlhttp = Nothing
%>
SERVER.ASHX
<%@ WebHandler Language="VB" Class="MyServerClass" %>
Imports System
Imports System.Web
Public Class MyServerClass : Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "text/plain"
context.Response.Write("hi there")
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
...my problem is that the myresults string in the client code is always blank. Question: How should the http-handle populate the responsetext property of the xmlhttp object which called it?
Addendum: I have also implemented the server.ashx as an aspx file, but myresults was still blank. Here is that code.
SERVER.ASPX
<%@ Page Language="VB" %>
<%
Response.ContentType = "text/plain"
Response.Write("hi there")
%>
Thanks in advance for the assistance! Peace, Henry E. Taylor