根据this MS link的信息,我在Windows CE / Compact Framework应用程序中获得了以下代码,该应用程序在Web API服务器应用程序中调用REST方法:
public static string SendXMLFile2(string uri, string data)
{
//TODO: Remove below after testing
String s = data.Substring(0, 128);
MessageBox.Show(String.Format("data length is {0}, uri is {1}, first part is {2}", data.Length, uri, s));
//TODO: Remove above after testing
HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create(uri);
myHttpWebRequest.AllowWriteStreamBuffering=false;
myHttpWebRequest.Method="POST";
UTF8Encoding encodedData = new UTF8Encoding();
//ASCIIEncoding encodedData=new ASCIIEncoding();
byte[] byteArray=encodedData.GetBytes(data);
//myHttpWebRequest.ContentType="application/x-www-form-urlencoded";
myHttpWebRequest.ContentType = "application/xml";
myHttpWebRequest.ContentLength=byteArray.Length;
Stream newStream=myHttpWebRequest.GetRequestStream();
newStream.Write(byteArray,0,byteArray.Length);
newStream.Close();
HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();
return myHttpWebResponse.StatusDescription;
}
我看到的是:
...然后我得到了" 远程服务器返回了一个错误:(400)错误请求。"
,当抛出/返回此异常时,甚至无法到达我的REST方法中的断点(在服务器上)为什么呢?我需要在代码中做些什么来改变"坏"请求考虑"好"?
要回答mrchief,请访问以下服务器代码:
[Route("api/inventory/sendXML/{userId}/{pwd}/{filename}")]
public async void SendInventoryXML(String userId, String pwd, String fileName)
{
XDocument doc = XDocument.Load(await Request.Content.ReadAsStreamAsync());
String saveLoc = String.Format(@"C:\HDP\{0}.xml", fileName);
doc.Save(saveLoc);
}
是的,我现在忽略了userId和pwd。
插入:
http://192.168.125.50:21608/api/inventory/sendXML/duckbilled/platypus/INV_bla.xml
...进入邮递员,我得到:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii">
</HEAD>
<BODY>
<h2>Bad Request - Invalid Hostname</h2>
<hr>
<p>HTTP Error 400. The request hostname is invalid.</p>
</BODY>
</HTML>
???当我从Visual Studio 2013中创建的Winforms应用程序调用它时,同样的uri工作正常。实际上,我在那里使用localhost。如果我使用主机名而不是IP地址,我会得到与上面相同的响应。但如果我使用PostMan的localhost:
http://localhost:21608/api/inventory/sendXML/duckbilled/platypus/INV_bla.xml
我明白了:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>IIS 8.0 Detailed Error - 404.0 - Not Found</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;}
code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;}
.config_source code{font-size:.8em;color:#000000;}
pre{margin:0;font-size:1.4em;word-wrap:break-word;}
ul,ol{margin:10px 0 10px 5px;}
ul.first,ol.first{margin-top:5px;}
fieldset{padding:0 15px 10px 15px;word-break:break-all;}
.summary-container fieldset{padding-bottom:5px;margin-top:4px;}
legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;}
legend{color:#333333;;margin:4px 0 8px -12px;_margin-top:0px;
font-weight:bold;font-size:1em;}
a:link,a:visited{color:#007EFF;font-weight:bold;}
a:hover{text-decoration:none;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.4em;margin:10px 0 0 0;color:#CC0000;}
h4{font-size:1.2em;margin:10px 0 5px 0;
}#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS",Verdana,sans-serif;
color:#FFF;background-color:#5C87B2;
}#content{margin:0 0 0 2%;position:relative;}
.summary-container,.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
.content-container p{margin:0 0 10px 0;
}#details-left{width:35%;float:left;margin-right:2%;
}#details-right{width:63%;float:left;overflow:hidden;
}#server_version{width:96%;_height:1px;min-height:1px;margin:0 0 5px 0;padding:11px 2% 8px 2%;color:#FFFFFF;
background-color:#5A7FA5;border-bottom:1px solid #C1CFDD;border-top:1px solid #4A6C8E;font-weight:normal;
font-size:1em;color:#FFF;text-align:right;
}#server_version p{margin:5px 0;}
table{margin:4px 0 4px 0;width:100%;border:none;}
td,th{vertical-align:top;padding:3px 0;text-align:left;font-weight:normal;border:none;}
th{width:30%;text-align:right;padding-right:2%;font-weight:bold;}
thead th{background-color:#ebebeb;width:25%;
}#details-right th{width:20%;}
table tr.alt td,table tr.alt th{}
.highlight-code{color:#CC0000;font-weight:bold;font-style:italic;}
.clear{clear:both;}
.preferred{padding:0 5px 2px 5px;font-weight:normal;background:#006633;color:#FFF;font-size:.8em;}
-->
</style>
</head>
<body>
<div id="content">
<div class="content-container">
<h3>HTTP Error 404.0 - Not Found</h3>
<h4>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</h4>
... ???是不是因为这是一个应该附加XML文件的POST,而且因为它不存在,它会被混乱消耗?
我看到&#34;。&#34; in&#34; INV_bla.xml&#34;让PostMan感到困惑。如果我删除它,以便URI为"http://localhost:21609/api/inventory/sendXML/duckbilled/platypus/INV_bla"
,我会得到一个500错误的消息,并且:
<!DOCTYPE html>
<html>
<head>
<title>Root element is missing.</title>
<meta name="viewport" content="width=device-width" />
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
@media screen and (max-width: 639px) {
pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
}
@media screen and (max-width: 479px) {
pre { width: 280px; }
}
</style>
</head>
<body bgcolor="white">
<span>
<H1>Server Error in '/' Application.
<hr width=100% size=1 color=silver>
</H1>
<h2>
<i>Root element is missing.</i>
</h2>
</span>
<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
<b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
<br>
<br>
<b> Exception Details: </b>System.Xml.XmlException: Root element is missing.
<br>
<br>
<b>Source Error:</b>
<br>
<br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code>
<pre>
Line 29: public async void SendInventoryXML(String userId, String pwd, String fileName)
Line 30: {
<font color=red>Line 31: XDocument doc = XDocument.Load(await Request.Content.ReadAsStreamAsync());
</font>Line 32: String saveLoc = String.Format(@"C:\HDP\{0}.xml", fileName);
Line 33: doc.Save(saveLoc);
</pre>
</code>
</td>
</tr>
</table>
<br>
<b> Source File: </b> c:\Project\git\CStore\HHS.Web\Controllers\InventoryXMLController.cs
<b> Line: </b> 31
<br>
<br>
<b>Stack Trace:</b>
<br>
<br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code>
<pre>
[XmlException: Root element is missing.]
System.Xml.XmlTextReaderImpl.Throw(Exception e) +69
System.Xml.XmlTextReaderImpl.ParseDocumentContent() +305
System.Xml.XmlTextReaderImpl.Read() +213
System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options) +44
System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options) +57
System.Xml.Linq.XDocument.Load(Stream stream) +6
HHS.Web.Controllers.<SendInventoryXML>d__0.MoveNext() in c:\Project\git\CStore\HHS.Web\Controllers\InventoryXMLController.cs:31
System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__0(Object state) +50
System.Web.<>c__DisplayClass7.<Post>b__6() +15
System.Web.Util.SynchronizationHelper.SafeWrapCallback(Action action) +91
</pre>
</code>
</td>
</tr>
</table>
<br>
<hr width=100% size=1 color=silver>
<b>Version Information:</b> Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446
</font>
</body>
</html>
<!--
[XmlException]: Root element is missing.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream)
at HHS.Web.Controllers.InventoryXMLController.<SendInventoryXML>d__0.MoveNext() in c:\Project\git\CStore\HHS.Web\Controllers\InventoryXMLController.cs:line 31
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__0(Object state)
at System.Web.AspNetSynchronizationContext.<>c__DisplayClass7.<Post>b__6()
at System.Web.Util.SynchronizationHelper.SafeWrapCallback(Action action)
-->
使用此代码(遵循Brinn的建议):
String datta = "<Content></Content>";
String s = SendXMLFile2(uri, datta);
MessageBox.Show(s); // TODO: Remove or comment out after testing
......我仍然收到400错误。
在Postman中有一个实际上可以使用的排列达到服务器代码(http://localhost:21608/api/inventory/sendXML/duckbill/platypus/INV_bla
)中的断点。但是,当我点击F10步骤从&#34; XDocument doc = ...&#34; line to the#34; String saveLoc = ...&#34; line,&#34; Root元素缺失&#34;异常被抛出(上面显示的是它的所有血腥荣耀)。
我不能在我的应用程序中使用完全相同的URI,因为&#34; localhost&#34;在那里是URI-non-grata。
抓住稻草,我甚至尝试过这个:
String xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
String crlf = "\r\n";
String datta = "<Content></Content>";
data = xmlHeader + crlf + datta + crlf;
String s = SendXMLFile2(uri, data);
...但是&#34; 400 Bad Request&#34;错误的遗骸,让我在我决定挂断马刺的那一刻懊恼。
即使我在Postman中添加XML文件,也会收到错误(500 - 内部服务器错误):
即使代码直接来自Wigley的口(来自&#34; Microsoft .NET Compact Framework&#34的第358页):
public static string SendXMLFile2(string uri, string data)
{
WebRequest req = WebRequest.Create(uri);
req.Method = "Post";
req.ContentType = "text/plain; charset=utf-8";
// Encode the data
byte[] encodedBytes = Encoding.UTF8.GetBytes(data);
req.ContentLength = encodedBytes.Length;
// Write encoded data into request stream
Stream requestStream = req.GetRequestStream();
requestStream.Write(encodedBytes, 0, encodedBytes.Length);
requestStream.Close();
WebResponse result = req.GetResponse();
return result.ToString();
}
...我得到了#34; 400 - 错误请求&#34; ERR。
是否可能是数据 - XML文件的内容 - 将扳手/扳手投入工程?
这里看起来像是什么(摘录,中间部分被忽略了):
<?xml version="1.0" encoding="utf-8"?>
<Command>
<INV>
<line_id>1</line_id>
<ref_no>valerie</ref_no>
<upc_code>79997000331</upc_code>
<description>ffff</description>
<department>2</department>
<vendor_id>1</vendor_id>
<upc_pack_size>1</upc_pack_size>
<id>79997000331</id>
<pack_size>1</pack_size>
<unit_cost>0</unit_cost>
<unit_list>0</unit_list>
<unit_qty>9</unit_qty>
<new_item>-1</new_item>
</INV>
<INV>
<line_id>2</line_id>
<ref_no>valerie</ref_no>
<upc_code>81127600412</upc_code>
<description>SLV EAG FF 100 BX</description>
<department>2.01</department>
<vendor_id>1</vendor_id>
<upc_pack_size>1</upc_pack_size>
<id>81127600412</id>
<pack_size>1</pack_size>
<unit_cost>0</unit_cost>
<unit_list>0</unit_list>
<unit_qty>9</unit_qty>
<new_item>0</new_item>
</INV>
. . .
<INV>
<line_id>3277</line_id>
<ref_no>valerie</ref_no>
<upc_code>00980000007</upc_code>
<description>TICTAC</description>
<department>8.8</department>
<vendor_id />
<upc_pack_size>1</upc_pack_size>
<id>00980000007</id>
<pack_size>1</pack_size>
<unit_cost>2</unit_cost>
<unit_list>3.55</unit_list>
<unit_qty>0</unit_qty>
<new_item>0</new_item>
</INV>
</Command>
我得到&#34;远程服务器返回错误:(400)错误请求&#34;在我的应用程序中现在我确实在Fiddler中看到两个有趣的条目:在Fiddler中有两个404显示
有&#34;主持人&#34; &#34; localhost:21609
&#34;的价值和&#34; localhost:21608
&#34; (与有问题的REST调用有关),&#34; URL&#34; /favicon.ico的值... ???
红色火焰是什么?他们有一个&#34; Body&#34;价值4,905,a&#34;缓存&#34;价值&#34;私人&#34;和&#34;内容类型&#34; of text / html;字符集= UTF8
为什么favicon.ico有问题,甚至在这里考虑?
这是Fiddler&#34; Log&#34;我&#34; faked&#34;的标签内容调用REST方法(使用Composer添加我的POST URI并上传XML文件):
09:14:20:9657 [WebSocket #1439] Read from Server failed... Object reference not set to an instance of an object.
09:23:19:7275 /Fiddler.CertMaker> Invoking makecert.exe with arguments: -pe -ss my -n "CN=www.google-analytics.com, O=DO_NOT_TRUST, OU=Created by http://www.fiddler2.com" -sky exchange -in DO_NOT_TRUST_FiddlerRoot -is my -eku 1.3.6.1.5.5.7.3.1 -cy end -a sha1 -m 132 -b 09/03/2013
09:23:20:1296 /Fiddler.CertMaker>64-CreateCert(www.google-analytics.com) => (0).
09:25:45:6411 [Fiddler] No HTTP request was received from (chrome:1384) new client socket, port 4235.
09:25:55:6411 [Fiddler] No HTTP request was received from (chrome:1384) new client socket, port 4241.
09:36:35:6681 [WebSocket #1473] Read from Client returned error: 0
09:36:35:7491 [WebSocket #1473] Read from Server returned error: 0
09:37:45:4031 [WebSocket #1552] Read from Client returned error: 0
09:37:45:4861 [WebSocket #1552] Read from Server returned error: 0
09:37:51:8077 [WebSocket #1575] Read from Client returned error: 0
09:37:51:8877 [WebSocket #1575] Read from Server returned error: 0
我认为可能&#34;对象引用未设置为对象的实例&#34;在我的服务器代码中指出某些内容可能是问题 - 但是关键部分甚至没有达到......事实是我在服务器中调用async / await代码可能导致我的困境? ?
唯一的变化是&#34; 21609&#34;成为&#34; 21608&#34;在我的网址中,Fiddler现在给了我一个&#34; 500&#34; (&#34;内部服务器错误&#34;)结果(当使用21609我得到&#34; 204&#34;结果,但它没有工作)。
有了这个端口号,真正的&#34;肉和土豆&#34;在服务器上访问代码(调用XDocument.Load()的async / await代码等。
Fiddler的Inspectors.WebView标签显示我:
这个xml不是从这一行开始的问题:
<?xml version="1.0" encoding="utf-8"?>
...因此不被视为有效/真实的XML?
没有 - 甚至带有包含该xml起始行的文件,它以同样的方式失败......
因此,根据使用的客户端,我会得到不同的结果:
From the handheld device, I get a "/favicon.ico" err in Fiddler.
From Fiddler itself (using the "Composer" tab) I get, "Data at the root level is invalid. Line 1, position 1"
From a test Winforms app, the code works (the expected file is populated and saved where it should be) but there is no trace in Fiddler that an HTTP call was even made (there is no entry/evidence for it)...???
服务器应用程序在Global.asax.cs中具有此功能:
RouteTable.Routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
......那么......问题是什么?
我注意到我可以从这个位置获取我的服务器应用程序生成的跟踪日志文件:C:\ Users \\ Documents \ IISExpress \ TraceLogFiles \
在那里,我找到了众所周知的大量信息(超载?),例如:
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type='text/xsl' href='freb.xsl'?>
<!-- saved from url=(0014)about:internet -->
<failedRequest url="http://localhost:21609/"
siteId="40"
appPoolId="Clr4IntegratedAppPool"
processId="10580"
verb="GET"
remoteUserName=""
userName=""
tokenUserName="SSCS\clay"
authenticationType="anonymous"
activityId="{00000000-0000-0000-1D00-0080020000ED}"
failureReason="STATUS_CODE"
statusCode="200"
triggerStatusCode="403.14"
timeTaken="62"
xmlns:freb="http://schemas.microsoft.com/win/2006/06/iis/freb"
>
. . .
令我印象深刻的是动词&#34; GET&#34; - 这是&#34; POST&#34;不是&#34; GET&#34; - 或者我误解了&#34;动词&#34;构件?
我测试了三种调用REST方法的不同方法,检查了使用Fiddler和服务器创建的跟踪日志文件时发生的最佳情况。
Winforms(Visual Studio 2013,.NET 4)应用程序中唯一成功调用和执行服务器代码(接收文件,然后将其保存到磁盘)。
以下是从这三次尝试中收集到的一些细节:
[a] EXE在手持设备上: 400 - 错误请求 服务器控制器代码中的断点未到达 Fiddler没有看到任何活动 摘要:失败 - 达到服务器,但返回错误信息
Pertinent contents of Log Trace file:
[ no log trace file created ]
[b]测试Winforms应用: 服务器控制器代码IS中的断点 Fiddler没有看到任何活动(?!?) 方法工作 - 文件由服务器代码创建,其中包含应有的数据 总结:有效,但是&#34;看不见&#34;给提琴手
Pertinent contents of Log Trace file:
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type='text/xsl' href='freb.xsl'?>
<!-- saved from url=(0014)about:internet -->
<failedRequest url="http://localhost:21608/api/inventory/sendXML/duckbill/Platypus/DSD_42314_3_20140310140842828" siteId="41" appPoolId="Clr4IntegratedAppPool" processId="8916"
verb="POST"
remoteUserName=""
userName=""
tokenUserName="NRBQ\clay"
authenticationType="anonymous"
activityId="{00000000-0000-0000-5D00-0080000000F6}"
failureReason="STATUS_CODE"
statusCode="204"
triggerStatusCode="204"
timeTaken="3666"
xmlns:freb="http://schemas.microsoft.com/win/2006/06/iis/freb"
>
[c] Fiddler&#34;作曲家&#34; 服务器控制器代码IS中的断点 活动见于Fiddler 结果= 500(&#34;内部服务器错误&#34;) 摘要:比掌上电脑更进一步,但失败
Pertinent contents of Log Trace file:
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type='text/xsl' href='freb.xsl'?>
<!-- saved from url=(0014)about:internet -->
<failedRequest url="http://localhost:21608/api/inventory/sendXML/duckbill/platypus/INV_bla"
siteId="41"
appPoolId="Clr4IntegratedAppPool"
processId="8916"
verb="POST"
remoteUserName=""
userName=""
tokenUserName="NRBQ\clay"
authenticationType="anonymous"
activityId="{00000000-0000-0000-4800-0080060000F6}"
failureReason="STATUS_CODE"
statusCode="500"
triggerStatusCode="204"
timeTaken="2964"
xmlns:freb="http://schemas.microsoft.com/win/2006/06/iis/freb"
>
可能是我的编码错了吗?似乎情况可能就是这样,基于我在研究错误消息时所读到的here(&#34; 根级别的数据无效。第1行,第1位。&#34)
这就是我在客户端做的事情:
WebRequest req = WebRequest.Create(uri);
req.Method = "Post";
req.ContentType = "text/plain; charset=utf-8";
byte[] encodedBytes = Encoding.UTF8.GetBytes(data);
ContentType应该是&#34; application / xml&#34;或&#34; application / x-www-form-urlencoded&#34; (或其他)相反? 和/或编码应该是UTF8以外的东西吗?
我注意到在C:\ Users \ clay \ Documents \ IISExpress \ TraceLogFiles \中我得到了一个&#34; 403.14&#34;:
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type='text/xsl' href='freb.xsl'?>
<!-- saved from url=(0014)about:internet -->
<failedRequest url="http://localhost:21609/"
siteId="40"
appPoolId="Clr4IntegratedAppPool"
processId="1572"
verb="GET"
remoteUserName=""
userName=""
tokenUserName="SSCS\clay"
authenticationType="anonymous"
activityId="{00000000-0000-0000-0200-0080060000EB}"
failureReason="STATUS_CODE"
statusCode="200"
triggerStatusCode="403.14"
timeTaken="904"
xmlns:freb="http://schemas.microsoft.com/win/2006/06/iis/freb"
>
根据this,更具体地说,this表示&#34;目录列表被拒绝。&#34;
认为这可能是问题的症结所在,我研究了如何处理403.14,然后我按照方法1 here进行了操作,其标题为&#34;添加默认文档(推荐)&#34 ;但实际上包含了在IIS&#34;
中启用目录浏览功能的步骤但我仍然在C:\ Users \ clay \ Documents \ IISExpress \ TraceLogFiles \
中获得相同的triggerStatusCode(&#34; 403.14&#34;)所以我也会尝试其他方法,但我已经有了一个默认文档,因此启用不是一个选项(禁用)。
最后,我选择了更新IIS Express配置的最终选项:
虽然这使得网页在运行服务器时看起来更好(403.14被替换为&#34; localhost - /&#34; dir列表),但当客户端应用程序尝试发送XML时没有区别文件到服务器。所以,这最后改变了#34;固定&#34;服务器启动时在浏览器中显示的页面,但我仍然看到&#34; 403.14&#34;我尝试从客户端应用程序访问服务器时跟踪日志文件中的问题...... ???
使用最新的更改(设置IIS配置),跟踪日志不再具有&#34; 403.14&#34;:
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type='text/xsl' href='freb.xsl'?>
<failedRequest url="http://localhost:21609/"
. . .
verb="GET"
. . .
failureReason="STATUS_CODE"
statusCode="200"
triggerStatusCode="200"
timeTaken="78"
xmlns:freb="http://schemas.microsoft.com/win/2006/06/iis/freb"
>
...所以我想&#34; 400 - Bad Request&#34;从客户端调用它时从服务器获取的错误与此以前的403.14错误无关。还要注意,它是&#34; failedRequest&#34;是一些&#34; GET&#34;操作(而来自客户端的失败调用是HttpPost)。什么是失败?我不知道,因为statusCode 200实际上是&#34; OK&#34;
我第一次(仅)启动服务器(或启动然后从客户端调用服务器),我得到一个404缺少的图标,但这似乎并不是一个问题。
解决方案是在命令提示符下添加:
netsh http add urlacl url=http://shannon2:80/ user=everyone
...或者端口8080而不是80。
请参阅更新5 here。
答案 0 :(得分:1)