Rest ASP Example
This page describes how to get an ASP application to work with the PUT and DELETE verbs under IIS on Windows XP Professional. Other versions of IIS / Windows may vary in configuration, but the process should be almost identically.
Open up the IIS configuration manager. Click the [Properties]-button on the web application that should support the PUT and DELETE verbs.
On the Directory tab, click the [Configuration]-button.
On the Mappings tab, find the .asp extension and click the [Edit]-button.
In the Verbs section, either check All Verbs or add PUT and DELETE to the comma-separated list in Limit to: and keep this one checked.
Click [OK] in all the windows.
The requesting script
Now, the application is configured, and it's just to write a test script. To test PUT and DELETE functionality, we need a way to request an ASP-script directly from ASP-code, and not via HTML forms etc. The way to do this, is to use the ServerXMLHttp object. This is the code for the requesting script:
<%@ Language = "VBScript" LCID = 1044 %> <% Option Explicit Response.CharSet = "ISO-8859-1" Response.ContentType = "text/plain" Response.Buffer = True Response.Expires = 0 Dim xmlhttp Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0") ' Open up a connection to the receiving script with a method of "PUT" Call xmlhttp.open("PUT", "http://localhost/test/verb_test2.asp", False) ' Send some data xmlhttp.send("<feed><title>Hello!</title></feed>") ' This will contain the response from verbtest2 in plain text. There are other response-properties ' as well, like "responseBody", "responseStream" and "responseXML". Response.Write(xmlhttp.responseText) %>
The receiving script
And this is the code for the receiving script:
<%@ Language = "VBScript" LCID = 1044 %> <% Option Explicit Response.CharSet = "ISO-8859-1" Response.ContentType = "text/plain" Response.Buffer = True Response.Expires = 0 ' This function converts a byte array to a conventional string Function BinaryToString(Binary) Dim i, s For i = 1 To LenB(Binary) s = s & Chr(AscB(MidB(Binary, i, 1))) Next BinaryToString = s End Function ' This will output whatever received from the requesting/sending script above Response.Write(BinaryToString(Request.BinaryRead(Request.TotalBytes))) %>
Original Author: AsbjornUlsberg