我正在尝试在另一个端口上的同一台机器上创建对 WEB API 的调用。它工作正常,发回字符串并命中.NET断点,但参数从未被传递..(它为空)..在经典的 ASP 代码中我是否缺少传递该字符串的内容?(数据发送)
我的调用代码:
<%
Response.Buffer = True
Dim xml
' Set xml = Server.CreateObject("Microsoft.XMLHTTP")
Set xml = server.Createobject("MSXML2.XMLHTTP")
DataToSend="<?xml version=""1.0"" encoding=""UTF-8""?><codes sku=""123123"" num-codes=""234234"" />"
xml.Open "POST", _
"http://localhost:1303/api/RegistrationCode", _
False
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.setRequestHeader "X-VitalSource-API-Key", "xxx"
xml.Send DataToSend
'Display the HTML both as HTML and as text
Response.Write "<h1>The HTML text</h1><xmp>"
Response.Write xml.responseText
Response.Write "</xmp><p><hr><p><h1>The HTML Output</h1>"
Response.Write xml.responseText
Set xml = Nothing
%>
WEB API 代码:
public class RegistrationCodeController : ApiController
{
string testXmlString = "<SomeValue>6</SomeValue>";
public string Post([FromBody]string value)
{
return testXmlString;
}
}