【问题标题】:Declaration Expected Error声明预期错误
【发布时间】:2014-03-05 03:05:41
【问题描述】:

我正在尝试阅读 asp.net 中的 rss 提要。我找到了以下代码让我开始。行:

 WebRequest request=WebRequest.Create("myfeedurl");

返回错误“需要声明”。我一生都无法弄清楚可能出了什么问题或预期声明的含义。任何帮助将不胜感激我在下面的部分中发布了我拥有的所有内容。

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%@ Import Namespace="System.Xml" %> 
<%@ Import Namespace="System.IO" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<script runat="server"> 
WebRequest request=WebRequest.Create("myfeedurl");
WebRequest response=request.GetResponse();

Stream rssStream=response.GetResponseStream();
XMLDocument xmlDoc=new XMLDocument();
xmlDoc.Load(rssStream);
</script>

</body>
</html>

【问题讨论】:

    标签: asp.net vb.net


    【解决方案1】:

    您正在 VB.Net 中尝试 C# 代码。

    你的代码应该是:

    Dim request As WebRequest = WebRequest.Create("myfeedurl")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-02
      相关资源
      最近更新 更多