C# 获取包含javascript的网页的响应
在我的C#应用程序中,我得到了以下代码:C# 获取包含javascript的网页的响应,c#,javascript,C#,Javascript,在我的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(myU
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>
登录超时
函数重定向TOTOP(reloginLoc){
if(opener!=null&&opener!=self){
opener.top.location=reloginLoc;
window.close();
}
否则如果(顶部!=自身){
top.location=reloginLoc;
}
否则{
位置=重新登录;
}
}
您的浏览器不支持JavaScript。请打开JavaScript以使用此网页的功能。
我不明白的是为什么它会说:“您的浏览器不支持JavaScript。请打开JavaScript以使用此网页的功能。
”,因为我在当前浏览器和IE中都激活了JavaScript
在我的Internet浏览器中,页面看起来不同,执行了脚本,我想知道如何在C#浏览器中激活javascript以获得完整响应。您正在获得完整响应
如果浏览器不支持javascript,则会包含noscript标记。对于此页面,服务器可能总是在响应中包含此内容-这并不一定意味着您的浏览器不支持javascript。我怀疑您实际上在寻找的是“模拟用户代理”。。。差不多