在我的C#应用程序中,我得到了以下代码:
private void button1_Click(object sender, EventArgs e)
{
string uri = urlTextBox.Text;
Uri myURL;
if (!Uri.TryCreate(uri, UriKind.Absolute, out myURL))
return;
WebRequest request = WebRequest.Create(myURL);
request.Method = "GET";
using (WebResponse response = request.GetResponse())
{
using (Stream stream = response.GetResponseStream())
{
using(StreamReader sr = new StreamReader(stream))
{
responseTextBox.Text = sr.ReadToEnd();
}
}
}
}
但是当我点击按钮时,它会返回以下文字:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Login Timed Out</title>
<link rel=stylesheet type="text/css" href="../../shared/css/ilearn_base.css">
<script>
function redirectToTop(reloginLoc) {
if (opener != null && opener != self) {
opener.top.location = reloginLoc;
window.close();
}
else if (top != self) {
top.location = reloginLoc;
}
else {
location = reloginLoc;
}
}
</script>
<noscript>
Your browser does not support JavaScript. Please turn on JavaScript to use the features of this web page.
</noscript>
</head>
<body onLoad="redirectToTop('../../learner/jsp/relogin_site.jsp')">
</body>
</html>
我无法理解的是为什么它会说:“Your browser does not support JavaScript. Please turn on JavaScript to use the features of this web page.
”,因为我在当前浏览器和IE中激活了JavaScript。
在我的互联网浏览器中,页面看起来不同,执行了脚本,我想知道如何在C#浏览器中激活javascript以获得完整的响应。
答案 0 :(得分:2)
您收到了完整的回复。
如果您的浏览器不支持javascript,则会包含noscript标记。对于此页面,服务器可能始终在响应中包含此内容 - 这并不一定意味着您的浏览器不支持javascript。