• Question

  • I have never made a API in vb only in C# using the project preset up as an api project. Here is the code I have given to me. I have never worked with IHttpHandler before so I'm not even sure how to handle routing etc. 

    Imports System.Web
    Imports System.Web.Services
    Imports Collage.Helpers.Components
    Imports Collage.Business
    Imports Newtonsoft.Json
    Namespace api
        Public Class change
            Implements System.Web.IHttpHandler
            Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
                Dim oChangeOrder As ChangeOrder, oResponse As Domain.Structures.Structures.ReturnResponse
                Dim Input_sr As StreamReader
                Dim sData As String
                Dim sReturn As String
                    Input_sr = New StreamReader(context.Request.InputStream)
                    sData = Input_sr.ReadToEnd
                    If context.Request.ContentType.StartsWith("application/xml") Then
                        oChangeOrder = New ChangeOrder(sData, False)
                        oResponse = oChangeOrder.Process
                        context.Response.StatusCode = HttpStatusCode.OK
                        If oResponse.ReturnCode = "Error" Then
                            sReturn = String.Format(Utils._sOrderErrorXML, oResponse.Message, oResponse.Message)
                            sReturn = String.Format(Utils._sOrderOkXML, oResponse.Message)
                        End If
                        sReturn = String.Format(Utils._sOrderErrorXML, "Error", "Invalid content type")
                    End If
                Catch ex As Exception
                    context.Response.StatusCode = HttpStatusCode.BadRequest
                    Utils.ErrorEmail("Change Error!", ex, AttachmentName:="Change.xml", AttachmentData:=sData)
                    sReturn = String.Format(Utils._sOrderErrorXML, "Error", ex.Message)
                End Try
                context.Response.ContentType = "application/xml"
            End Sub
            ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
                    Return False
                End Get
            End Property
        End Class
    End Namespace

    I have no idea what this is or how to work with it. Anyone have any information about this and how to route it etc? 

    • Edited by old_School Wednesday, October 9, 2019 4:23 PM
    Wednesday, October 9, 2019 12:54 PM

All replies

  • Hi,

    This is an document about IHttpHandler.

    Hope it will be helpful.

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Thursday, October 10, 2019 5:41 AM
  • It looks like some school project.

    Myself, I would be looking into using HTTPClinet the de facto.

    Thursday, October 10, 2019 10:16 AM