pun*_*ter 18 xml asp.net-mvc fiddler
使用Fiddler我可以传入身体
someXml = ThisShouldBeXml
然后在控制器中
[HttpPost]
public ActionResult Test(object someXml)
{
return Json(someXml);
}
Run Code Online (Sandbox Code Playgroud)
将此数据作为字符串获取
如何让fiddler将XML传递给MVC ActionController?如果我尝试将正文中的值设置为原始xml,则它不起作用..
对于奖励积分,我如何从VBscript/Classic ASP执行此操作?
我现在有
DataToSend = "name=JohnSmith"
Dim xml
Set xml = server.Createobject("MSXML2.ServerXMLHTTP")
xml.Open "POST", _
"http://localhost:1303/Home/Test", _
False
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.send DataToSend
Run Code Online (Sandbox Code Playgroud)
小智 10
您无法直接将XML数据作为文件传递给MVC控制器.最好的方法之一是将XML数据作为Stream传递给HTTP post.
对于发布XML,
有关将XML发布到MVC Controller的更多详细信息,请参阅此stackoverflow文章
要在控制器中检索XML,请使用以下方法
[HttpPost]
public ActionResult Index()
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
// as XML: deserialize into your own object or parse as you wish
var responseXml = XDocument.Load(response.GetResponseStream());
//in responseXml variable you will get the XML data
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15355 次 |
| 最近记录: |