有哪位大侠能否帮下忙,求一程序,实现将js文件时的代码原样显示在ie里。  如:我在ie中键入:http://127.0.0.1/demoforjs.aspx?url=http://www.people.com.cn/paper/rmrb/range.js,就能原样显示出range.js里代码在浏览器中。    说明:http://127.0.0.1/自已建立的web服务器。
     demoforjs.aspx:需写的程序名称。
     url:即程序的参数名.
         http://www.people.com.cn/paper/rmrb/range.js:参数值。

解决方案 »

  1.   

    用HTTPRequest类读取URL地址的内容,在显示可以了
      

  2.   

    <%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            string u = Request.QueryString["url"];
            System.Net.HttpWebRequest webRequest = System.Net.WebRequest.Create(u) as System.Net.HttpWebRequest;
            webRequest.Method = "GET";        // write the form values into the request message
            System.IO.StreamReader sr = new System.IO.StreamReader(webRequest.GetResponse().GetResponseStream(), System.Text.Encoding.GetEncoding("GB2312"));
            TextBox1.Text = sr.ReadToEnd();
            sr.Close();
        }  
    </script><html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server" Height="553px" TextMode="MultiLine" Width="815px"></asp:TextBox>
        </form>
    </body>
    </html>
      

  3.   

    public static string getPageCode(String url  )
            {
                
                string strReturn = null ;
                System.Net.HttpWebResponse resp = null;
                try
                {
                    
                    System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
                    req.Method = "GET";
                    req.ContentType = "application/x-www-form-urlencoded";
                    req.AllowAutoRedirect = false;
                    req.ContentLength = 0;
                    resp = (System.Net.HttpWebResponse)req.GetResponse();
                    System.IO.Stream sr = resp.GetResponseStream();                
                    System.IO.StreamReader srReader = new System.IO.StreamReader(sr);                strReturn = srReader.ReadToEnd();
                    
                     
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    if (resp != null)
                    {
                        resp.Close();
                    }
                }            return strReturn;
            }