我有一个jsp页面,它从某个url读取一行并发送给客户端:
<%@page import="java.util.*" %>
<%@page import="java.net.*" %>
<%@page import="java.io.*" %>
<%
URL myUrl = new URL("http://host.com");
BufferedReader in = new BufferedReader(
new InputStreamReader(
myUrl.openStream()));
out.println(in.readLine());
%>
我想为 IIS 提供相同的功能:
<%@ Page Language="C#">
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<%
WebRequest myWebRequest = WebRequest.Create("http://www.host.com");
WebResponse myWebResponse = myWebRequest.GetResponse();
Stream ReceiveStream = myWebResponse.GetResponseStream();
StreamReader reader = new StreamReader(ReceiveStream);
Response.Write(reader.ReadLine());
%>
但我收到一个错误代码:错误类型:Active Server Pages, ASP 0221 (0x80004005) 指定的 'Page Language="C#"> <%@ Import Namespace="System.IO" ' 选项未知或无效。index.asp,第 1 行
我做错了什么?