当我在模拟器上请求网页时,我得到了 HTML,但是当我从设备发出请求时(我在 wifi 和蜂窝网络上尝试过)。这种情况始终如一地发生。
什么会导致这个?
编辑:这是在设备上为我返回的内容,在模拟器上我得到了真实页面:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Error</title>
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name=ProgId content=VisualStudio.HTML>
<meta name=Originator content="Microsoft Visual Studio .NET 7.1">
<link rel="stylesheet" id="style" runat="server" type="text/css" href="Data/style/mojo1.css" />
</head>
<body >
<br /><br />
<table ID="Table1">
<tr>
<td width="100"></td>
<td align="center">
</td>
</tr>
<tr>
<td width="100"></td>
<td width="500">
<p style="font-family:arial sans-serif;font-size:large">
Sorry!
</p>
<p style="font-family:arial sans-serif;font-size:large">
A server error has occurred.<br />
The error has been logged and will be reviewed as soon as possible.
It may have been a momentary problem; use the back button to try again or go back to the
<a href="http://metrotransit.org/home.aspx">home</a> page.
For assistance, call 612-373-3333 to speak with a transit representative.
</p>
</td>
</tr>
</table>
</body>
</html>
编辑:我知道它不是用户代理。我进行了自定义配置,问题仍然存在。
编辑:问题继续与 NSURLRequest 以及 NSURLSession。