net 1.1 代码格式例子

<%@ Page language="c#" AutoEventWireup="true" %>
<%@ Import namespace="System.Net" %>
<%@ Import namespace="System.IO" %>
<script language="C#" runat="server" >
public string strTest = "none";
private void Page_Load(object sender, System.EventArgs e)
{

   string strRedirectPath = "http://211.151.49.27/clickheat/click.php" + Request.Url.Query;
   System.Uri url = new Uri(strRedirectPath);

   string strReferer = "http://www.mybmwclub.cn";
   if (Request.UrlReferrer != null)
    strReferer = Request.UrlReferrer.AbsoluteUri;

   HttpWebRequest r = (HttpWebRequest) WebRequest.CreateDefault(url);
   r.Referer = strReferer;
   r.UserAgent = Request.UserAgent;
   
   WebResponse myresponse = r.GetResponse();
   
   try
   {
    StreamReader streamReader = new StreamReader(myresponse.GetResponseStream(),true);               
    try
    {
     strTest = streamReader.ReadToEnd();
    }
    finally
    {
     streamReader.Close();
    }
   }
   finally
   {
    myresponse.Close();
   }


}
</script>
<%=strTest%>

你可能感兴趣的:(server,object,String,C#,url,import)