基于OpenLayers的代理文件内容 GeoServerProxy?URL
基于OpenLayers的代理文件内容 GeoServerProxy?URL
public partial class GeoServerProxy : BaseWebForm
{
protected override void Page_Load(object sender, EventArgs e)
{
if (Page.Request.QueryString["URL"] != null)
{
string url = "";
HttpWebResponse loWebResponse = null;
StreamReader loResponseStream = null;
try
{
url = Page.Request.QueryString["URL"].ToString();
HttpWebRequest loHttp = (HttpWebRequest)WebRequest.Create(url);
loHttp.Timeout = 10000; // 10 secs
loHttp.UserAgent = "Web Client";
loWebResponse = (HttpWebResponse)loHttp.GetResponse();
Encoding enc = Encoding.GetEncoding(65001);
loResponseStream = new StreamReader(loWebResponse.GetResponseStream(), enc);
string lcHtml = loResponseStream.ReadToEnd();
Response.Write(lcHtml);
}
catch (Exception ee)
{
//
}
finally
{
if (loWebResponse != null)
{
loWebResponse.Close();
loWebResponse = null;
}
if (loResponseStream != null)
{
loResponseStream.Close();
loResponseStream = null;
}
}
}
}
}
转载自:https://blog.csdn.net/hsg77/article/details/22332295